diff options
author | Marc Poulhiès <poulhies@adacore.com> | 2023-02-09 09:36:14 +0100 |
---|---|---|
committer | Marc Poulhiès <poulhies@adacore.com> | 2023-05-22 10:44:11 +0200 |
commit | eb16654e44775841f82488311fcf08ef521756d9 (patch) | |
tree | 427854133150b63c1ffb989e8a051881266732bf /gcc/ada/sem_attr.adb | |
parent | c58d5574ae74c414c73558288fad42c229695881 (diff) | |
download | gcc-eb16654e44775841f82488311fcf08ef521756d9.zip gcc-eb16654e44775841f82488311fcf08ef521756d9.tar.gz gcc-eb16654e44775841f82488311fcf08ef521756d9.tar.bz2 |
ada: Fix crash caused by incorrect expansion of iterated component
The way iterated component are expanded could lead to inconsistent tree.
This change fixes 2 issues:
- in an early step during Pre_Analyze, the loop variable still has
Any_Type and the compiler must not emit an error. A later full Analyze
is supposed to correctly set the Etype, and only then should the
compiler emit an error if Any_Type is still used.
- when expanding into a loop with assignments statement, the expression
is analyzed in an early context (where the loop variable still has
Any_Type Etype) and then copied. The compiler would crash because this
Any_Type is never changed because the expression node has its Analyzed
flag set. Resetting the flag ensures the later Analyze call also
analyzes these nodes and set Etype correctly.
gcc/ada/
* exp_aggr.adb (Process_Transient_Component): Reset Analyzed flag
for the copy of the initialization expression.
* sem_attr.adb (Validate_Non_Static_Attribute_Function_Call): Skip
error emission during Pre_Analyze.
Diffstat (limited to 'gcc/ada/sem_attr.adb')
-rw-r--r-- | gcc/ada/sem_attr.adb | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/gcc/ada/sem_attr.adb b/gcc/ada/sem_attr.adb index a07e91b..bc4e3cf 100644 --- a/gcc/ada/sem_attr.adb +++ b/gcc/ada/sem_attr.adb @@ -3319,7 +3319,9 @@ package body Sem_Attr is -- Check for missing/bad expression (result of previous error) - if No (E1) or else Etype (E1) = Any_Type then + if No (E1) + or else (Etype (E1) = Any_Type and then Full_Analysis) + then Check_Error_Detected; raise Bad_Attribute; end if; |