]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Fix assertion failure introduced by latest change
authorEric Botcazou <ebotcazou@adacore.com>
Wed, 5 Jul 2023 17:49:40 +0000 (19:49 +0200)
committerEric Botcazou <ebotcazou@adacore.com>
Wed, 27 Sep 2023 08:16:29 +0000 (10:16 +0200)
The new processing is not properly guarded.

gcc/ada/

* sem_ch13.adb (Replace_Type_References_Generic.Visible_Component):
In the case of private discriminated types, explicitly check that we
have a private declaration before examining its discriminant part.

gcc/ada/sem_ch13.adb

index d66255cdd9edfb05d8daef91eb342a3136653cdd..b81b6b02e1d3494ce3bcf2c799e14f9ff146e358 100644 (file)
@@ -15463,8 +15463,6 @@ package body Sem_Ch13 is
          elsif Is_Private_Type (T) and then Has_Discriminants (T) then
             declare
                Decl : constant Node_Id := Declaration_Node (T);
-               Spec : constant List_Id :=
-                 Discriminant_Specifications (Original_Node (Decl));
 
                Discr : Node_Id;
 
@@ -15474,8 +15472,11 @@ package body Sem_Ch13 is
                --  name; then, if it exists, return the discriminant entity of
                --  the same name in the type, which is that of its full view.
 
-               if Present (Spec) then
-                  Discr := First (Spec);
+               if Nkind (Decl) in N_Private_Extension_Declaration
+                                | N_Private_Type_Declaration
+                 and then Present (Discriminant_Specifications (Decl))
+               then
+                  Discr := First (Discriminant_Specifications (Decl));
 
                   while Present (Discr) loop
                      if Chars (Defining_Identifier (Discr)) = Comp then