Skip to content

Commit

Permalink
Merge branch 'topic/1168' into 'master'
Browse files Browse the repository at this point in the history
Fix p_is_static_expr regarding AttributeRefs

Closes #1168

See merge request eng/libadalang/libadalang!1489
  • Loading branch information
thvnx committed Dec 11, 2023
2 parents 28e6d97 + c63dabe commit 2864709
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 2 deletions.
2 changes: 1 addition & 1 deletion ada/ast.py
Original file line number Diff line number Diff line change
Expand Up @@ -13138,7 +13138,7 @@ def is_static_expr():

ar.prefix.name_designated_type
._.is_static_decl & ar.attribute.name_symbol.any_of(
'First', 'Last', 'Range', 'Val'
'First', 'Last', 'Range', 'Val', 'Pos'
),

ar.prefix.referenced_decl._.is_array
Expand Down
23 changes: 23 additions & 0 deletions testsuite/tests/properties/is_static_expr_2/enum.adb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
procedure Enum is
type My_Enum is (A, B, C, D, E);

Min : constant := My_Enum'Pos (My_Enum'First);
--% node.f_expr.p_is_static_expr()

Max : constant := My_Enum'Pos (My_Enum'Last);
--% node.f_expr.p_is_static_expr()

type R1 is range Min .. Max;
--% range = node.f_type_def.f_range.f_range
--% range.f_left.p_is_static_expr()
--% range.f_right.p_is_static_expr()
--% node.p_is_static_decl()

type R2 is range My_Enum'Pos (My_Enum'First) .. My_Enum'Pos (My_Enum'Last);
--% range = node.f_type_def.f_range.f_range
--% range.f_left.p_is_static_expr()
--% range.f_right.p_is_static_expr()
--% node.p_is_static_decl()
begin
null;
end Enum;
42 changes: 42 additions & 0 deletions testsuite/tests/properties/is_static_expr_2/test.out
Original file line number Diff line number Diff line change
@@ -1,3 +1,45 @@
Working on node <NumberDecl ["Min"] enum.adb:4:4-4:50>
======================================================

Eval 'node.f_expr.p_is_static_expr()'
Result: True

Working on node <NumberDecl ["Max"] enum.adb:7:4-7:49>
======================================================

Eval 'node.f_expr.p_is_static_expr()'
Result: True

Working on node <ConcreteTypeDecl ["R1"] enum.adb:10:4-10:32>
=============================================================

Set 'range' to 'node.f_type_def.f_range.f_range'
Result: <BinOp enum.adb:10:21-10:31>

Eval 'range.f_left.p_is_static_expr()'
Result: True

Eval 'range.f_right.p_is_static_expr()'
Result: True

Eval 'node.p_is_static_decl()'
Result: True

Working on node <ConcreteTypeDecl ["R2"] enum.adb:16:4-16:79>
=============================================================

Set 'range' to 'node.f_type_def.f_range.f_range'
Result: <BinOp enum.adb:16:21-16:78>

Eval 'range.f_left.p_is_static_expr()'
Result: True

Eval 'range.f_right.p_is_static_expr()'
Result: True

Eval 'node.p_is_static_decl()'
Result: True

Working on node <ForLoopStmt foo.adb:5:4-7:13>
==============================================

Expand Down
2 changes: 1 addition & 1 deletion testsuite/tests/properties/is_static_expr_2/test.yaml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
driver: inline-playground
input_sources: [foo.adb]
input_sources: [foo.adb, enum.adb]

0 comments on commit 2864709

Please sign in to comment.