[multiple changes]
authorArnaud Charlet <charlet@gcc.gnu.org>
Fri, 5 Oct 2012 14:33:42 +0000 (16:33 +0200)
committerArnaud Charlet <charlet@gcc.gnu.org>
Fri, 5 Oct 2012 14:33:42 +0000 (16:33 +0200)
2012-10-05  Robert Dewar  <dewar@adacore.com>

* sem_ch7.adb: Minor reformatting.

2012-10-05  Ed Schonberg  <schonberg@adacore.com>

* sem_prag.adb (Analyze_Pragma, case Persistent_BSS): check for
a duplicate pragma before Rep_Item_Too_Late to prevent spurious
messages about duplicate pragmas.

2012-10-05  Ed Schonberg  <schonberg@adacore.com>

* exp_util.adb (Find_Init_Call): If the successor of the
object declaration is a block, check whether it contains the
initialization call, because it may have been created by actuals
that use the secondary stack.

From-SVN: r192130

gcc/ada/ChangeLog
gcc/ada/exp_util.adb
gcc/ada/sem_ch7.adb
gcc/ada/sem_prag.adb

index ea4667fb2ce7fcdd8a03eb122bd49274987a9ec8..1a9ff91cf3f6c525e83314566da4d85b7be221b0 100644 (file)
@@ -1,3 +1,20 @@
+2012-10-05  Robert Dewar  <dewar@adacore.com>
+
+       * sem_ch7.adb: Minor reformatting.
+
+2012-10-05  Ed Schonberg  <schonberg@adacore.com>
+
+       * sem_prag.adb (Analyze_Pragma, case Persistent_BSS): check for
+       a duplicate pragma before Rep_Item_Too_Late to prevent spurious
+       messages about duplicate pragmas.
+
+2012-10-05  Ed Schonberg  <schonberg@adacore.com>
+
+       * exp_util.adb (Find_Init_Call): If the successor of the
+       object declaration is a block, check whether it contains the
+       initialization call, because it may have been created by actuals
+       that use the secondary stack.
+
 2012-10-05  Thomas Quinot  <quinot@adacore.com>
 
        * sem_dim.adb, errout.adb, errout.ads (Analyze_Dimension_Call): Add
index 82b054adfcea3a9f36c305a542694d86ac747891..cc3213d03da6b0f862598daa72a5cb8bffb3cb47 100644 (file)
@@ -2166,6 +2166,7 @@ package body Exp_Util is
      (Var        : Entity_Id;
       Rep_Clause : Node_Id) return Node_Id
    is
+      Par : constant Node_Id   := Parent (Var);
       Typ : constant Entity_Id := Etype (Var);
 
       Init_Proc : Entity_Id;
@@ -2204,6 +2205,7 @@ package body Exp_Util is
 
    begin
       if not Has_Non_Null_Base_Init_Proc (Typ) then
+
          --  No init proc for the type, so obviously no call to be found
 
          return Empty;
@@ -2213,7 +2215,7 @@ package body Exp_Util is
 
       --  First scan the list containing the declaration of Var
 
-      Init_Call := Find_Init_Call_In_List (From => Next (Parent (Var)));
+      Init_Call := Find_Init_Call_In_List (From => Next (Par));
 
       --  If not found, also look on Var's freeze actions list, if any, since
       --  the init call may have been moved there (case of an address clause
@@ -2224,6 +2226,23 @@ package body Exp_Util is
            Find_Init_Call_In_List (First (Actions (Freeze_Node (Var))));
       end if;
 
+      --  If the initialization call has actuals that use the secondary stack,
+      --  the call may have been wrapped into a temporary block, in which case
+      --  the block itself has to be removed.
+
+      if No (Init_Call) and then Nkind (Next (Par)) = N_Block_Statement then
+         declare
+            Blk : constant Node_Id := Next (Par);
+         begin
+            if Present
+                 (Find_Init_Call_In_List
+                   (First (Statements (Handled_Statement_Sequence (Blk)))))
+            then
+               Init_Call := Blk;
+            end if;
+         end;
+      end if;
+
       return Init_Call;
    end Find_Init_Call;
 
index 103aa5b2bdd5b02e9925c533e98d25d25ea5cca3..a25e32833386b9c3e5f373aa77271d8545f38c40 100644 (file)
@@ -1390,11 +1390,13 @@ package body Sem_Ch7 is
          then
             declare
                ASN : Node_Id;
+
             begin
                ASN := First (Aspect_Specifications (Parent (E)));
                while Present (ASN) loop
                   if Chars (Identifier (ASN)) = Name_Invariant
-                    or else Chars (Identifier (ASN)) = Name_Type_Invariant
+                       or else
+                     Chars (Identifier (ASN)) = Name_Type_Invariant
                   then
                      Build_Invariant_Procedure (E, N);
                      exit;
index 1739673bf06c39d22fd4a4cce6cdba5f227427cb..2c9d518f67058db1c3179e79f3840fe9d28e4603 100644 (file)
@@ -12130,6 +12130,11 @@ package body Sem_Prag is
                Ent := Entity (Get_Pragma_Arg (Arg1));
                Decl := Parent (Ent);
 
+               --  Check for duplication before inserting in list of
+               --  representation items.
+
+               Check_Duplicate_Pragma (Ent);
+
                if Rep_Item_Too_Late (Ent, N) then
                   return;
                end if;
@@ -12145,8 +12150,6 @@ package body Sem_Prag is
                      Arg1);
                end if;
 
-               Check_Duplicate_Pragma (Ent);
-
                Prag :=
                  Make_Linker_Section_Pragma
                    (Ent, Sloc (N), ".persistent.bss");