diff options
Diffstat (limited to 'gcc/ada')
-rw-r--r-- | gcc/ada/sem_attr.adb | 4 | ||||
-rw-r--r-- | gcc/ada/sem_ch13.adb | 12 |
2 files changed, 13 insertions, 3 deletions
diff --git a/gcc/ada/sem_attr.adb b/gcc/ada/sem_attr.adb index 72f5ab4..d56c25a 100644 --- a/gcc/ada/sem_attr.adb +++ b/gcc/ada/sem_attr.adb @@ -1843,7 +1843,9 @@ package body Sem_Attr is if Nkind (P) = N_Aspect_Specification then return P_Type = Entity (P); - elsif Nkind (P) in N_Declaration then + -- Prevent the search from going too far + + elsif Is_Body_Or_Package_Declaration (P) then return False; end if; diff --git a/gcc/ada/sem_ch13.adb b/gcc/ada/sem_ch13.adb index 4012932..a86f774 100644 --- a/gcc/ada/sem_ch13.adb +++ b/gcc/ada/sem_ch13.adb @@ -1037,11 +1037,19 @@ package body Sem_Ch13 is Parent_Type : Entity_Id; + Save_In_Spec_Expression : constant Boolean := In_Spec_Expression; + begin -- Ensure Expr is analyzed so that e.g. all types are properly - -- resolved for Find_Type_Reference. + -- resolved for Find_Type_Reference. We preanalyze this expression + -- as a spec expression (to avoid recursive freezing), while skipping + -- resolution (to not fold type self-references, e.g. T'Last). - Analyze (Expr); + In_Spec_Expression := True; + + Preanalyze (Expr); + + In_Spec_Expression := Save_In_Spec_Expression; -- A self-referential aspect is illegal if it forces freezing the -- entity before the corresponding aspect has been analyzed. |