[Ada] Complete support for prefixed call on subtypes/derived types

Message ID 20211109094544.GA830021@adacore.com
State Committed
Commit ea8726cac5af33305fa81886beb4ab2255f99567
Headers
Series [Ada] Complete support for prefixed call on subtypes/derived types |

Commit Message

Pierre-Marie de Rodat Nov. 9, 2021, 9:45 a.m. UTC
  Definition of subtypes and derived types needs to possibly initialize
the list meant to store primitive operations when -gnatX is used.

Tested on x86_64-pc-linux-gnu, committed on trunk

gcc/ada/

	* sem_ch3.adb (Analyze_Subtype_Declaration,
	Derived_Type_Declaration): Initialize list of primitive
	operations when Extensions_Allowed.
  

Patch

diff --git a/gcc/ada/sem_ch3.adb b/gcc/ada/sem_ch3.adb
--- a/gcc/ada/sem_ch3.adb
+++ b/gcc/ada/sem_ch3.adb
@@ -5755,6 +5755,15 @@  package body Sem_Ch3 is
                   if Is_Tagged_Type (Id) then
                      Set_No_Tagged_Streams_Pragma
                        (Id, No_Tagged_Streams_Pragma (T));
+                  end if;
+
+                  --  For tagged types, or when prefixed-call syntax is allowed
+                  --  for untagged types, initialize the list of primitive
+                  --  operations to an empty list.
+
+                  if Is_Tagged_Type (Id)
+                    or else Extensions_Allowed
+                  then
                      Set_Direct_Primitive_Operations (Id, New_Elmt_List);
                   end if;
 
@@ -17199,8 +17208,12 @@  package body Sem_Ch3 is
          Set_Etype        (T, Any_Type);
          Set_Scalar_Range (T, Scalar_Range (Any_Type));
 
-         if Is_Tagged_Type (T)
-           and then Is_Record_Type (T)
+         --  For tagged types, or when prefixed-call syntax is allowed for
+         --  untagged types, initialize the list of primitive operations to
+         --  an empty list.
+
+         if (Is_Tagged_Type (T) and then Is_Record_Type (T))
+           or else Extensions_Allowed
          then
             Set_Direct_Primitive_Operations (T, New_Elmt_List);
          end if;