[multiple changes]
authorPierre-Marie de Rodat <pmderodat@gcc.gnu.org>
Tue, 5 Dec 2017 11:38:00 +0000 (11:38 +0000)
committerPierre-Marie de Rodat <pmderodat@gcc.gnu.org>
Tue, 5 Dec 2017 11:38:00 +0000 (11:38 +0000)
2017-12-05  Bob Duff  <duff@adacore.com>

* exp_ch6.adb (Build_In_Place_Formal): Search for the formal by suffix
instead of the full name.
* sem_ch6.adb (Create_Extra_Formals): Make sure there are extra formals
in the case of an instance of a generic.

2017-12-05  Arnaud Charlet  <charlet@adacore.com>

(Adjust_Global_Switches): Create an alias GNAT_Annotate to map to
pragma Annotate.

From-SVN: r255409

gcc/ada/ChangeLog
gcc/ada/exp_ch6.adb
gcc/ada/gnat1drv.adb
gcc/ada/sem_ch6.adb
gcc/ada/snames.ads-tmpl

index 79417dd..d5e64b0 100644 (file)
@@ -1,3 +1,15 @@
+2017-12-05  Bob Duff  <duff@adacore.com>
+
+       * exp_ch6.adb (Build_In_Place_Formal): Search for the formal by suffix
+       instead of the full name.
+       * sem_ch6.adb (Create_Extra_Formals): Make sure there are extra formals
+       in the case of an instance of a generic.
+
+2017-12-05  Arnaud Charlet  <charlet@adacore.com>
+
+       (Adjust_Global_Switches): Create an alias GNAT_Annotate to map to
+       pragma Annotate.
+
 2017-12-05  Sebastian Huber  <sebastian.huber@embedded-brains.de>
 
        * gcc-interface/Makefile.in (RTEMS): Define EH_MECHANISM.
index 0b36110..8a3f390 100644 (file)
@@ -650,9 +650,7 @@ package body Exp_Ch6 is
      (Func : Entity_Id;
       Kind : BIP_Formal_Kind) return Entity_Id
    is
-      Formal_Name  : constant Name_Id :=
-                       New_External_Name
-                         (Chars (Func), BIP_Formal_Suffix (Kind));
+      Formal_Suffix : constant String := BIP_Formal_Suffix (Kind);
       Extra_Formal : Entity_Id := Extra_Formals (Func);
 
    begin
@@ -669,9 +667,21 @@ package body Exp_Ch6 is
          Extra_Formal := Extra_Formals (Func);
       end if;
 
+      --  We search for a formal with a matching suffix. We can't search
+      --  for the full name, because of the code at the end of Sem_Ch6.-
+      --  Create_Extra_Formals, which copies the Extra_Formals over to
+      --  the Alias of an instance, which will cause the formals to have
+      --  "incorrect" names.
+
       loop
          pragma Assert (Present (Extra_Formal));
-         exit when Chars (Extra_Formal) = Formal_Name;
+         declare
+            Name : constant String := Get_Name_String (Chars (Extra_Formal));
+         begin
+            exit when Name'Length >= Formal_Suffix'Length
+              and then Formal_Suffix =
+                Name (Name'Last - Formal_Suffix'Length + 1 .. Name'Last);
+         end;
 
          Next_Formal_With_Extras (Extra_Formal);
       end loop;
index 3e4234b..1b3f9a3 100644 (file)
@@ -136,6 +136,13 @@ procedure Gnat1drv is
    --  Start of processing for Adjust_Global_Switches
 
    begin
+      --  Define pragma GNAT_Annotate as an alias of pragma Annotate,
+      --  to be able to work around bootstrap limitations with the old syntax
+      --  of pragma Annotate, and use pragma GNAT_Annotate in compiler sources
+      --  when needed.
+
+      Map_Pragma_Name (From => Name_Gnat_Annotate, To => Name_Annotate);
+
       --  -gnatd.M enables Relaxed_RM_Semantics
 
       if Debug_Flag_Dot_MM then
index 01c1b54..b13ca92 100644 (file)
@@ -8140,6 +8140,13 @@ package body Sem_Ch6 is
                 (E, Formal_Typ, E, BIP_Formal_Suffix (BIP_Object_Access));
          end;
       end if;
+
+      --  If this is an instance of a generic, we need to have extra formals
+      --  for the Alias.
+
+      if Is_Generic_Instance (E) and then Present (Alias (E)) then
+         Set_Extra_Formals (Alias (E), Extra_Formals (E));
+      end if;
    end Create_Extra_Formals;
 
    -----------------------------
index 5fcf365..e89e3ff 100644 (file)
@@ -760,6 +760,7 @@ package Snames is
    Name_Gcc                            : constant Name_Id := N + $;
    Name_General                        : constant Name_Id := N + $;
    Name_Gnat                           : constant Name_Id := N + $;
+   Name_Gnat_Annotate                  : constant Name_Id := N + $;
    Name_Gnat_Extended_Ravenscar        : constant Name_Id := N + $;
    Name_Gnat_Ravenscar_EDF             : constant Name_Id := N + $;
    Name_Gnatprove                      : constant Name_Id := N + $;