Skip to content

Commit

Permalink
Merge branch 'topic/1142' into 'master'
Browse files Browse the repository at this point in the history
Fix identity_type property to support ParamSpec

Closes #1143

See merge request eng/libadalang/libadalang!1471
  • Loading branch information
thvnx committed Nov 21, 2023
2 parents 8c452c0 + 7c53a48 commit c478a29
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 3 deletions.
4 changes: 3 additions & 1 deletion ada/ast.py
Original file line number Diff line number Diff line change
Expand Up @@ -3024,8 +3024,10 @@ def identity_type():
# An object decl on which you can call 'Identity implies that its
# type is a task type.
lambda _=T.ObjectDecl: Self.task_id_type,
# As well as for for loop variable declarations
# As well as for for loop variable declarations and parameter
# specifications.
lambda _=T.ForLoopVarDecl: Self.task_id_type,
lambda _=T.BaseFormalParamDecl: Self.task_id_type,
lambda _: No(T.BaseTypeDecl.entity)
)

Expand Down
15 changes: 14 additions & 1 deletion testsuite/tests/name_resolution/identity_attr/test.adb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ procedure Test is
end TT;

X : TT;
X_Array : array (1 .. 10) of T;
X_Array : array (1 .. 10) of TT;
begin
if T'Identity = X'Identity then
null;
Expand All @@ -34,4 +34,17 @@ begin
end if;
pragma Test_Statement_UID;
end loop;

-- Should also work on ParamSpec
declare
function F
(A_Task : TT;
Compare : Ada.Task_Identification.Task_ID) return Boolean is
begin
return A_Task'Identity /= Compare;
pragma Test_Statement_UID;
end F;
begin
null;
end;
end Test;
29 changes: 28 additions & 1 deletion testsuite/tests/name_resolution/identity_attr/test.out
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ Expr: <AttributeRef test.adb:32:10-32:20>
expected type: ada.task_identification.task_id
Expr: <Id "I" test.adb:32:10-32:11>
references: test().i
type: None
type: test().tt
expected type: None
Expr: <Id "Identity" test.adb:32:12-32:20>
references: None
Expand Down Expand Up @@ -114,5 +114,32 @@ Expr: <Id "Current_Task" test.adb:32:47-32:59>
type: ada.task_identification.task_id
expected type: ada.task_identification.task_id

Resolving xrefs for node <ReturnStmt test.adb:44:10-44:44>
**********************************************************

Expr: <RelationOp test.adb:44:17-44:43>
type: standard.boolean
expected type: standard.boolean
Expr: <AttributeRef test.adb:44:17-44:32>
references: None
type: ada.task_identification.task_id
expected type: ada.task_identification.task_id
Expr: <Id "A_Task" test.adb:44:17-44:23>
references: test().f((test.tt, ada.task_identification.task_id) -> standard.boolean).a_task
type: test().tt
expected type: None
Expr: <Id "Identity" test.adb:44:24-44:32>
references: None
type: None
expected type: None
Expr: <OpNeq "/=" test.adb:44:33-44:35>
references: ada.task_identification."="((ada.task_identification.task_id, ada.task_identification.task_id) -> standard.boolean)
type: None
expected type: None
Expr: <Id "Compare" test.adb:44:36-44:43>
references: test().f((test.tt, ada.task_identification.task_id) -> standard.boolean).compare
type: ada.task_identification.task_id
expected type: ada.task_identification.task_id


Done.

0 comments on commit c478a29

Please sign in to comment.