Skip to content

Commit

Permalink
Merge branch 'topic/1416' into 'master'
Browse files Browse the repository at this point in the history
Add support for Passed_By_Reference attribute

Closes #1416

See merge request eng/libadalang/libadalang!1699
  • Loading branch information
thvnx committed Jul 17, 2024
2 parents 5ccceef + 27b1227 commit 4f2a579
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 1 deletion.
8 changes: 7 additions & 1 deletion ada/nodes.lkt
Original file line number Diff line number Diff line change
Expand Up @@ -12647,7 +12647,13 @@ class AttributeRef: Name {
elif rel_name == s"Result" then self.result_attr_equation()
elif rel_name in s"Old" | s"Loop_Entry" then self.bind_to_prefix_eq()
elif rel_name in s"Class" | s"Base" then self.prefix.sub_equation()
elif rel_name in s"Valid" | s"Machine_Overflows" | s"Machine_Rounds" | s"Has_Access_Values" | s"Has_Discriminants" | s"Has_Tagged_Values" | s"Definite" | s"Constrained" | s"Initialized" | s"Valid_Scalars" | s"Unconstrained_Array" | s"Library_Level" | s"Preelaborable_Initialization" | s"Denorm" | s"Signed_Zeros" | s"Fast_Math" then self.prefix.sub_equation() and %eq(node.type_var(), node.bool_type())
elif rel_name in s"Valid" | s"Machine_Overflows" | s"Machine_Rounds"
| s"Has_Access_Values" | s"Has_Discriminants" | s"Has_Tagged_Values"
| s"Definite" | s"Constrained" | s"Initialized" | s"Valid_Scalars"
| s"Unconstrained_Array" | s"Library_Level"
| s"Preelaborable_Initialization" | s"Denorm" | s"Signed_Zeros"
| s"Fast_Math" | s"Passed_By_Reference" then
self.prefix.sub_equation() and %eq(node.type_var(), node.bool_type())
# In the case of the ``Enabled`` attribute, the prefix is supposed
# to be a check name, so it's not even an entity that has source
# existence. In that case, we just bind the type of the expr to
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
procedure Test is
B : Boolean := Integer'Passed_By_Reference;
pragma Test_Statement;
begin
null;
end;
25 changes: 25 additions & 0 deletions testsuite/tests/name_resolution/passed_by_reference_attr/test.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
Analyzing test.adb
##################

Resolving xrefs for node <ObjectDecl ["B"] test.adb:2:4-2:47>
*************************************************************

Expr: <Id "Boolean" test.adb:2:8-2:15>
references: <DefiningName "Boolean" __standard:3:8-3:15>
type: None
expected type: None
Expr: <AttributeRef test.adb:2:19-2:46>
references: None
type: <ConcreteTypeDecl ["Boolean"] __standard:3:3-3:33>
expected type: <ConcreteTypeDecl ["Boolean"] __standard:3:3-3:33>
Expr: <Id "Integer" test.adb:2:19-2:26>
references: <DefiningName "Integer" __standard:4:8-4:15>
type: <ConcreteTypeDecl ["Integer"] __standard:4:3-4:54>
expected type: None
Expr: <Id "Passed_By_Reference" test.adb:2:27-2:46>
references: None
type: None
expected type: None


Done.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
driver: name-resolution
input_sources: [test.adb]

0 comments on commit 4f2a579

Please sign in to comment.