diff options
author | Eric Botcazou <ebotcazou@adacore.com> | 2023-12-12 18:05:40 +0100 |
---|---|---|
committer | Marc Poulhiès <poulhies@adacore.com> | 2024-01-09 14:13:31 +0100 |
commit | fc48e3b206039b4bc7e636f13a8f65d80d93b2d4 (patch) | |
tree | 8d0d68642e4dd8300907540d3a1f544841e88fdb /gcc | |
parent | 4784601d726e5b70b6c4e050c77749706536ccf3 (diff) | |
download | gcc-fc48e3b206039b4bc7e636f13a8f65d80d93b2d4.zip gcc-fc48e3b206039b4bc7e636f13a8f65d80d93b2d4.tar.gz gcc-fc48e3b206039b4bc7e636f13a8f65d80d93b2d4.tar.bz2 |
ada: Fix internal error on class-wide allocator inside if-expression
The problem is that the freeze node for the class-wide subtype built for the
expression of the allocator escapes from the dependent expression instead of
being stored in its list of actions.
gcc/ada/
* freeze.adb (Freeze_Expression.Has_Decl_In_List): Deal specifically
with itypes that are class-wide subtypes.
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ada/freeze.adb | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/gcc/ada/freeze.adb b/gcc/ada/freeze.adb index 26b5589..468d6ee 100644 --- a/gcc/ada/freeze.adb +++ b/gcc/ada/freeze.adb @@ -8141,10 +8141,19 @@ package body Freeze is Decl_Node : Node_Id; begin - -- If E is an itype, pretend that it is declared in N + -- If E is an itype, pretend that it is declared in N except for a + -- class-wide subtype with an equivalent type, because this latter + -- type comes with a bona-fide declaration node. if Is_Itype (E) then - Decl_Node := N; + if Ekind (E) = E_Class_Wide_Subtype + and then Present (Equivalent_Type (E)) + then + Decl_Node := Declaration_Node (Equivalent_Type (E)); + else + Decl_Node := N; + end if; + else Decl_Node := Declaration_Node (E); end if; |