Skip to content

Commit

Permalink
Test concatenation with visible overloads.
Browse files Browse the repository at this point in the history
  • Loading branch information
Roldak committed Nov 22, 2023
1 parent e3b2915 commit f59cbfc
Show file tree
Hide file tree
Showing 5 changed files with 145 additions and 0 deletions.
3 changes: 3 additions & 0 deletions testsuite/tests/name_resolution/concat_op_overloading/pkg.ads
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package Pkg is
function "&" (X, Y : String) return String is (X);
end Pkg;
16 changes: 16 additions & 0 deletions testsuite/tests/name_resolution/concat_op_overloading/test.adb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
with Ada.Text_IO;
with Pkg;

procedure Test is
use Pkg;

A, B : constant String := "hello";

C : String := "&" (A, B);
pragma Test_Statement;
D : String := A & B;
pragma Test_Statement;
begin
Ada.Text_IO.Put_Line (C);
Ada.Text_IO.Put_Line (D);
end Test;
109 changes: 109 additions & 0 deletions testsuite/tests/name_resolution/concat_op_overloading/test.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
Analyzing test.adb
##################

Resolving xrefs for node <ObjectDecl ["C"] test.adb:9:4-9:29>
*************************************************************

Expr: <Id "String" test.adb:9:8-9:14>
references: <DefiningName "String" __standard:105:8-105:14>
type: None
expected type: None
Expr: <CallExpr test.adb:9:18-9:28>
references: <SyntheticDefiningName ""&"" __standard:105:18-105:56>
type: <ConcreteTypeDecl ["String"] __standard:105:3-105:57>
expected type: <ConcreteTypeDecl ["String"] __standard:105:3-105:57>
Expr: <Str ""&"" test.adb:9:18-9:21>
references: <SyntheticDefiningName ""&"" __standard:105:18-105:56>
type: <ConcreteTypeDecl ["String"] __standard:105:3-105:57>
expected type: None
Expr: <Id "A" test.adb:9:23-9:24>
references: <DefiningName "A" test.adb:7:4-7:5>
type: <ConcreteTypeDecl ["String"] __standard:105:3-105:57>
expected type: <ConcreteTypeDecl ["String"] __standard:105:3-105:57>
Expr: <Id "B" test.adb:9:26-9:27>
references: <DefiningName "B" test.adb:7:7-7:8>
type: <ConcreteTypeDecl ["String"] __standard:105:3-105:57>
expected type: <ConcreteTypeDecl ["String"] __standard:105:3-105:57>

Resolving xrefs for node <ObjectDecl ["D"] test.adb:11:4-11:24>
***************************************************************

Expr: <Id "String" test.adb:11:8-11:14>
references: <DefiningName "String" __standard:105:8-105:14>
type: None
expected type: None
Expr: <ConcatOp test.adb:11:18-11:23>
type: <ConcreteTypeDecl ["String"] __standard:105:3-105:57>
expected type: <ConcreteTypeDecl ["String"] __standard:105:3-105:57>
Expr: <Id "A" test.adb:11:18-11:19>
references: <DefiningName "A" test.adb:7:4-7:5>
type: <ConcreteTypeDecl ["String"] __standard:105:3-105:57>
expected type: <ConcreteTypeDecl ["String"] __standard:105:3-105:57>
Expr: <ConcatOperand test.adb:11:20-11:23>
type: <ConcreteTypeDecl ["String"] __standard:105:3-105:57>
expected type: <ConcreteTypeDecl ["String"] __standard:105:3-105:57>
Expr: <OpConcat "&" test.adb:11:20-11:21>
references: <DefiningName ""&"" pkg.ads:2:13-2:16>
type: None
expected type: None
Expr: <Id "B" test.adb:11:22-11:23>
references: <DefiningName "B" test.adb:7:7-7:8>
type: <ConcreteTypeDecl ["String"] __standard:105:3-105:57>
expected type: <ConcreteTypeDecl ["String"] __standard:105:3-105:57>


Analyzing test_2.adb
####################

Resolving xrefs for node <ObjectDecl ["C"] test_2.adb:8:4-8:29>
***************************************************************

Expr: <Id "String" test_2.adb:8:8-8:14>
references: <DefiningName "String" __standard:105:8-105:14>
type: None
expected type: None
Expr: <CallExpr test_2.adb:8:18-8:28>
references: <DefiningName ""&"" test_2.adb:4:13-4:16>
type: <ConcreteTypeDecl ["String"] __standard:105:3-105:57>
expected type: <ConcreteTypeDecl ["String"] __standard:105:3-105:57>
Expr: <Str ""&"" test_2.adb:8:18-8:21>
references: <DefiningName ""&"" test_2.adb:4:13-4:16>
type: <ConcreteTypeDecl ["String"] __standard:105:3-105:57>
expected type: None
Expr: <Id "A" test_2.adb:8:23-8:24>
references: <DefiningName "A" test_2.adb:6:4-6:5>
type: <ConcreteTypeDecl ["String"] __standard:105:3-105:57>
expected type: <ConcreteTypeDecl ["String"] __standard:105:3-105:57>
Expr: <Id "B" test_2.adb:8:26-8:27>
references: <DefiningName "B" test_2.adb:6:7-6:8>
type: <ConcreteTypeDecl ["String"] __standard:105:3-105:57>
expected type: <ConcreteTypeDecl ["String"] __standard:105:3-105:57>

Resolving xrefs for node <ObjectDecl ["D"] test_2.adb:10:4-10:24>
*****************************************************************

Expr: <Id "String" test_2.adb:10:8-10:14>
references: <DefiningName "String" __standard:105:8-105:14>
type: None
expected type: None
Expr: <ConcatOp test_2.adb:10:18-10:23>
type: <ConcreteTypeDecl ["String"] __standard:105:3-105:57>
expected type: <ConcreteTypeDecl ["String"] __standard:105:3-105:57>
Expr: <Id "A" test_2.adb:10:18-10:19>
references: <DefiningName "A" test_2.adb:6:4-6:5>
type: <ConcreteTypeDecl ["String"] __standard:105:3-105:57>
expected type: <ConcreteTypeDecl ["String"] __standard:105:3-105:57>
Expr: <ConcatOperand test_2.adb:10:20-10:23>
type: <ConcreteTypeDecl ["String"] __standard:105:3-105:57>
expected type: <ConcreteTypeDecl ["String"] __standard:105:3-105:57>
Expr: <OpConcat "&" test_2.adb:10:20-10:21>
references: <DefiningName ""&"" test_2.adb:4:13-4:16>
type: None
expected type: None
Expr: <Id "B" test_2.adb:10:22-10:23>
references: <DefiningName "B" test_2.adb:6:7-6:8>
type: <ConcreteTypeDecl ["String"] __standard:105:3-105:57>
expected type: <ConcreteTypeDecl ["String"] __standard:105:3-105:57>


Done.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
driver: name-resolution
input_sources: [test.adb, test_2.adb]
15 changes: 15 additions & 0 deletions testsuite/tests/name_resolution/concat_op_overloading/test_2.adb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
with Ada.Text_IO;

procedure Test_2 is
function "&" (X, Y : String) return String is (X);

A, B : constant String := "hello";

C : String := "&" (A, B);
pragma Test_Statement;
D : String := A & B;
pragma Test_Statement;
begin
Ada.Text_IO.Put_Line (C);
Ada.Text_IO.Put_Line (D);
end Test_2;

0 comments on commit f59cbfc

Please sign in to comment.