diff options
Diffstat (limited to 'gcc/ada/sem_ch13.adb')
-rw-r--r-- | gcc/ada/sem_ch13.adb | 30 |
1 files changed, 23 insertions, 7 deletions
diff --git a/gcc/ada/sem_ch13.adb b/gcc/ada/sem_ch13.adb index 04ed408..79b22cd 100644 --- a/gcc/ada/sem_ch13.adb +++ b/gcc/ada/sem_ch13.adb @@ -2264,13 +2264,29 @@ package body Sem_Ch13 is end if; end if; - -- Construct the attribute definition clause - - Aitem := - Make_Attribute_Definition_Clause (Loc, - Name => Ent, - Chars => Chars (Id), - Expression => Relocate_Node (Expr)); + -- Construct the attribute_definition_clause. The expression + -- in the aspect specification is simply shared with the + -- constructed attribute, because it will be fully analyzed + -- when the attribute is processed. However, in ASIS mode + -- the aspect expression itself is preanalyzed and resolved + -- to catch visibility errors that are otherwise caught + -- later, and we create a separate copy of the expression + -- to prevent analysis of a malformed tree (e.g. a function + -- call with parameter associations). + + if ASIS_Mode then + Aitem := + Make_Attribute_Definition_Clause (Loc, + Name => Ent, + Chars => Chars (Id), + Expression => New_Copy_Tree (Expr)); + else + Aitem := + Make_Attribute_Definition_Clause (Loc, + Name => Ent, + Chars => Chars (Id), + Expression => Relocate_Node (Expr)); + end if; -- If the address is specified, then we treat the entity as -- referenced, to avoid spurious warnings. This is analogous |