public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r11-1827] [Ada] Crash on declaration with aggregate for unchecked union
@ 2020-07-06 11:39 Pierre-Marie de Rodat
  0 siblings, 0 replies; only message in thread
From: Pierre-Marie de Rodat @ 2020-07-06 11:39 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:776afaf7fef4e8d73a2376778c648f8f9a6c536b

commit r11-1827-g776afaf7fef4e8d73a2376778c648f8f9a6c536b
Author: Ed Schonberg <schonberg@adacore.com>
Date:   Mon May 4 20:05:03 2020 -0400

    [Ada] Crash on declaration with aggregate for unchecked union
    
    gcc/ada/
    
            * sem_ch3.adb (Analyze_Object_Declaration): If the type is an
            Unchecked_Union, and the expression is an aggregate. complete
            the analysis and resolution of the aggregate, and treat like a
            regular object declaration, instead of as a renaming
            declarattion.

Diff:
---
 gcc/ada/sem_ch3.adb | 30 ++++++++++++++++++++----------
 1 file changed, 20 insertions(+), 10 deletions(-)

diff --git a/gcc/ada/sem_ch3.adb b/gcc/ada/sem_ch3.adb
index 9e60d75152d..c105f3c83e8 100644
--- a/gcc/ada/sem_ch3.adb
+++ b/gcc/ada/sem_ch3.adb
@@ -4564,16 +4564,26 @@ package body Sem_Ch3 is
                   Set_Ekind (Id, E_Variable);
                end if;
 
-               Rewrite (N,
-                 Make_Object_Renaming_Declaration (Loc,
-                   Defining_Identifier => Id,
-                   Subtype_Mark        => New_Occurrence_Of (T, Loc),
-                   Name                => E));
-
-               Set_Renamed_Object (Id, E);
-               Freeze_Before (N, T);
-               Set_Is_Frozen (Id);
-               goto Leave;
+               --  If the expression is an aggregate it contains the required
+               --  discriminant values but it has not been resolved yet, so do
+               --  it now, and treat it as the initial expression of an object
+               --  declaration, rather than a renaming.
+
+               if Nkind (E) = N_Aggregate then
+                  Analyze_And_Resolve (E, T);
+
+               else
+                  Rewrite (N,
+                    Make_Object_Renaming_Declaration (Loc,
+                      Defining_Identifier => Id,
+                      Subtype_Mark        => New_Occurrence_Of (T, Loc),
+                      Name                => E));
+
+                  Set_Renamed_Object (Id, E);
+                  Freeze_Before (N, T);
+                  Set_Is_Frozen (Id);
+                  goto Leave;
+               end if;
 
             else
                --  Ensure that the generated subtype has a unique external name


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-07-06 11:39 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-06 11:39 [gcc r11-1827] [Ada] Crash on declaration with aggregate for unchecked union Pierre-Marie de Rodat

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).