This slightly tweaks the null procedure generated for a subprogram
default in a generic instantiation: as per RM 12.6 (16 2/2), the
convention is explicitly set to Intrinsic, and the procedure is also
marked inlined.

This has two main effects: first, to help the algorithm computing the
setting of the Is_Public flag in the presence of inlined subprograms,
because this null procedure is somewhat irregular (its body is in the
spec of the package generated for the instantiation); second, to make
sure that the calls to the procedure are eliminated when optimization
is enabled, which seems the right thing to do.

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

2020-06-04  Eric Botcazou  <ebotca...@adacore.com>

gcc/ada/

        * sem_attr.adb (Resolve_Attribute) <Access>: Do not generate
        the secondary message about a missing pragma if the convention
        of the prefix is Intrinsic.
        * sem_ch12.adb (Instantiate_Formal_Subprogram): Only set the
        Convention and the Is_Inlined flag on a null procedure.
--- gcc/ada/sem_attr.adb
+++ gcc/ada/sem_attr.adb
@@ -10678,6 +10678,7 @@ package body Sem_Attr is
 
                      if not Is_Itype (Btyp)
                        and then not Has_Convention_Pragma (Btyp)
+                       and then Convention (Entity (P)) /= Convention_Intrinsic
                      then
                         Error_Msg_FE
                           ("\probable missing pragma Convention for &",

--- gcc/ada/sem_ch12.adb
+++ gcc/ada/sem_ch12.adb
@@ -10785,7 +10785,13 @@ package body Sem_Ch12 is
                Make_Handled_Sequence_Of_Statements (Loc,
                  Statements => New_List (Make_Null_Statement (Loc))));
 
-         Set_Is_Intrinsic_Subprogram (Defining_Unit_Name (New_Spec));
+         --  RM 12.6 (16 2/2): The procedure has convention Intrinsic
+
+         Set_Convention (Defining_Unit_Name (New_Spec), Convention_Intrinsic);
+
+         --  Eliminate the calls to it when optimization is enabled
+
+         Set_Is_Inlined (Defining_Unit_Name (New_Spec));
          return Decl_Node;
 
       else

Reply via email to