[Ada] Assertion errors on concurrent types with -gnatc and extensions enabled
authorGary Dismukes <dismukes@adacore.com>
Fri, 21 May 2021 17:59:30 +0000 (13:59 -0400)
committerPierre-Marie de Rodat <derodat@adacore.com>
Wed, 7 Jul 2021 16:23:19 +0000 (16:23 +0000)
gcc/ada/

* einfo-utils.adb (Primitive_Operations): Default to returning
Direct_Primitive_Operations in the case of concurrent types
(when Corresponding_Record_Type not present).
* sem_ch9.adb (Analyze_Protected_Type_Declaration): Initialize
Direct_Primitive_Operations to an empty element list.
(Analyze_Task_Type_Declaration): Initialize
Direct_Primitive_Operations to an empty element list.

gcc/ada/einfo-utils.adb
gcc/ada/sem_ch9.adb

index 22143d6..b2d8a84 100644 (file)
@@ -2493,15 +2493,15 @@ package body Einfo.Utils is
             return Direct_Primitive_Operations
               (Corresponding_Record_Type (Id));
 
-         --  If expansion is disabled the corresponding record type is absent,
-         --  but if the type has ancestors it may have primitive operations.
-
-         elsif Is_Tagged_Type (Id) then
-            return Direct_Primitive_Operations (Id);
+         --  When expansion is disabled, the corresponding record type is
+         --  absent, but if this is a tagged type with ancestors, or if the
+         --  extension of prefixed calls for untagged types is enabled, then
+         --  it may have associated primitive operations.
 
          else
-            return No_Elist;
+            return Direct_Primitive_Operations (Id);
          end if;
+
       else
          return Direct_Primitive_Operations (Id);
       end if;
index 969eff5..65f48a7 100644 (file)
@@ -2031,6 +2031,12 @@ package body Sem_Ch9 is
       Set_Has_Delayed_Freeze (T);
       Set_Stored_Constraint  (T, No_Elist);
 
+      --  Initialize type's primitive operations list, for possible use when
+      --  the extension of prefixed call notation for untagged types is enabled
+      --  (such as by use of -gnatX).
+
+      Set_Direct_Primitive_Operations (T, New_Elmt_List);
+
       --  Mark this type as a protected type for the sake of restrictions,
       --  unless the protected type is declared in a private part of a package
       --  of the runtime. With this exception, the Suspension_Object from
@@ -3152,6 +3158,12 @@ package body Sem_Ch9 is
       Set_Has_Delayed_Freeze (T, True);
       Set_Stored_Constraint  (T, No_Elist);
 
+      --  Initialize type's primitive operations list, for possible use when
+      --  the extension of prefixed call notation for untagged types is enabled
+      --  (such as by use of -gnatX).
+
+      Set_Direct_Primitive_Operations (T, New_Elmt_List);
+
       --  Set the SPARK_Mode from the current context (may be overwritten later
       --  with an explicit pragma).