]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Crash when using user defined string literals
authorJavier Miranda <miranda@adacore.com>
Thu, 6 Jun 2024 11:20:14 +0000 (11:20 +0000)
committerMarc Poulhiès <poulhies@adacore.com>
Fri, 21 Jun 2024 08:34:21 +0000 (10:34 +0200)
When a non-overridable aspect is explicitly specified for a
non-tagged derived type, the compiler blows up processing an
object declaration of an object of such type.

gcc/ada/

* sem_ch13.adb (Analyze_One_Aspect): Fix code locating the entity
of the parent type.

gcc/ada/sem_ch13.adb

index a86f774018a356c382bd9fd5b2d22e83346b4cad..90376f818a30e5e2114eb0093de281cf5cb81f08 100644 (file)
@@ -4801,8 +4801,14 @@ package body Sem_Ch13 is
               and then Nkind (Type_Definition (N)) = N_Derived_Type_Definition
               and then not In_Instance_Body
             then
+               --  In order to locate the parent type we must go first to its
+               --  base type because the frontend introduces an implicit base
+               --  type even if there is no constraint attached to it, since
+               --  this is closer to the Ada semantics.
+
                declare
-                  Parent_Type      : constant Entity_Id := Etype (E);
+                  Parent_Type      : constant Entity_Id :=
+                    Etype (Base_Type (E));
                   Inherited_Aspect : constant Node_Id :=
                     Find_Aspect (Parent_Type, A_Id);
                begin