diff options
author | Eric Botcazou <ebotcazou@adacore.com> | 2023-11-06 23:34:20 +0100 |
---|---|---|
committer | Marc Poulhiès <poulhies@adacore.com> | 2023-11-28 10:35:47 +0100 |
commit | e95a42ec9a6be3edb6d8e31273ffcf64a40c0d3d (patch) | |
tree | 8ed97a9e844283445ff6fb36024164e79a698b1c /gcc/ada/sem_ch3.adb | |
parent | 89ed5455850437782358e0b3fb399bb5d4ec5f65 (diff) | |
download | gcc-e95a42ec9a6be3edb6d8e31273ffcf64a40c0d3d.zip gcc-e95a42ec9a6be3edb6d8e31273ffcf64a40c0d3d.tar.gz gcc-e95a42ec9a6be3edb6d8e31273ffcf64a40c0d3d.tar.bz2 |
ada: Fix internal error on declare expression in expression function
When the expression function is not a completion, its (return) expression
does not cause freezing so analyzing the declare expression in this context
must not freeze the type of the object.
The change also contains another fix, which makes it so that the compiler
does not evaluate a nonstatic representation attribute of a scalar subtype
in the same context if the subtype is not already frozen.
gcc/ada/
* sem_attr.adb (Eval_Attribute): Do not proceed in a spec expression
for nonstatic representation attributes of a scalar subtype when the
subtype is not frozen.
* sem_ch3.adb (Analyze_Object_Declaration): Do not freeze the type
of the object in a spec expression.
Diffstat (limited to 'gcc/ada/sem_ch3.adb')
-rw-r--r-- | gcc/ada/sem_ch3.adb | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/gcc/ada/sem_ch3.adb b/gcc/ada/sem_ch3.adb index ca60850..aed7828 100644 --- a/gcc/ada/sem_ch3.adb +++ b/gcc/ada/sem_ch3.adb @@ -4453,7 +4453,8 @@ package body Sem_Ch3 is -- If not a deferred constant, then the object declaration freezes -- its type, unless the object is of an anonymous type and has delayed - -- aspects. In that case the type is frozen when the object itself is. + -- aspects (in that case the type is frozen when the object itself is) + -- or the context is a spec expression. else Check_Fully_Declared (T, N); @@ -4463,7 +4464,7 @@ package body Sem_Ch3 is and then Is_Itype (T) then Set_Has_Delayed_Freeze (T); - else + elsif not In_Spec_Expression then Freeze_Before (N, T); end if; end if; |