]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[multiple changes]
authorArnaud Charlet <charlet@gcc.gnu.org>
Mon, 1 Oct 2012 08:45:43 +0000 (10:45 +0200)
committerArnaud Charlet <charlet@gcc.gnu.org>
Mon, 1 Oct 2012 08:45:43 +0000 (10:45 +0200)
2012-10-01  Robert Dewar  <dewar@adacore.com>

* freeze.adb, sem_ch6.adb, opt.ads, sem_ch13.adb,
exp_ch3.adb: Minor reformatting.

2012-10-01  Hristian Kirtchev  <kirtchev@adacore.com>

* checks.adb (Build_PPC_Pragma): A PPC pragma can now be properly
associated with a subprogram body.

From-SVN: r191902

gcc/ada/ChangeLog
gcc/ada/checks.adb
gcc/ada/exp_ch3.adb
gcc/ada/freeze.adb
gcc/ada/opt.ads
gcc/ada/sem_ch13.adb
gcc/ada/sem_ch6.adb

index d0f86178e5721d53686f4fbbf460af12aa6e29a9..db3e9b826a087c34eb6fb70b8fd65088eecd72b8 100644 (file)
@@ -1,3 +1,13 @@
+2012-10-01  Robert Dewar  <dewar@adacore.com>
+
+       * freeze.adb, sem_ch6.adb, opt.ads, sem_ch13.adb,
+       exp_ch3.adb: Minor reformatting.
+
+2012-10-01  Hristian Kirtchev  <kirtchev@adacore.com>
+
+       * checks.adb (Build_PPC_Pragma): A PPC pragma can now be properly
+       associated with a subprogram body.
+
 2012-10-01  Ed Schonberg  <schonberg@adacore.com>
 
        * aspects.ads: Type_Invariant'class is a valid aspect.
index 885a5686c604a24e4ba3127c92451a4963f6515e..8d40abcb06e2590343e25664f8f7befcc0ec6bac 100644 (file)
@@ -1876,8 +1876,9 @@ package body Checks is
       ----------------------
 
       procedure Build_PPC_Pragma (PPC_Nam : Name_Id; Check : Node_Id) is
-         Loc  : constant Source_Ptr := Sloc (Subp);
-         Prag : Node_Id;
+         Loc   : constant Source_Ptr := Sloc (Subp);
+         Decls : List_Id;
+         Prag  : Node_Id;
 
       begin
          Prag :=
@@ -1904,11 +1905,34 @@ package body Checks is
 
          if Nkind (Parent (Subp_Decl)) = N_Compilation_Unit then
             Add_Global_Declaration (Prag);
+            Analyze (Prag);
+
+         --  PPC pragmas associated with subprogram bodies must be inserted in
+         --  the declarative part of the body.
+
+         elsif Nkind (Subp_Decl) = N_Subprogram_Body then
+            Decls := Declarations (Subp_Decl);
+
+            if No (Decls) then
+               Decls := New_List;
+               Set_Declarations (Subp_Decl, Decls);
+            end if;
+
+            Append_To (Decls, Prag);
+
+            --  Ensure the proper visibility of the subprogram body and its
+            --  parameters.
+
+            Push_Scope (Subp);
+            Analyze (Prag);
+            Pop_Scope;
+
+         --  For subprogram declarations insert the PPC pragma right after the
+         --  declarative node.
+
          else
-            Insert_After (Subp_Decl, Prag);
+            Insert_After_And_Analyze (Subp_Decl, Prag);
          end if;
-
-         Analyze (Prag);
       end Build_PPC_Pragma;
 
       --  Local variables
@@ -1941,10 +1965,11 @@ package body Checks is
         or else Is_Imported (Subp)
         or else Is_Intrinsic_Subprogram (Subp)
 
-         --  Do not consider subprogram bodies because pre and post conditions
-         --  cannot be associated with them.
+         --  The PPC pragmas generated by this routine do not correspond to
+         --  source aspects, therefore they cannot be applied to abstract
+         --  subprograms.
 
-        or else Nkind (Subp_Decl) /= N_Subprogram_Declaration
+        or else Nkind (Subp_Decl) = N_Abstract_Subprogram_Declaration
 
          --  Do not process null procedures because there is no benefit of
          --  adding the checks to a no action routine.
index 293c902389da568ef71931bbff6e95208ab8443f..cf993757406d6ecf60ae960e4770d708e9670437 100644 (file)
@@ -3626,7 +3626,7 @@ package body Exp_Ch3 is
       --  Name for argument of invariant procedure
 
       Object_Entity : constant Node_Id :=
-                        Make_Defining_Identifier (Loc, Object_Name);
+        Make_Defining_Identifier (Loc, Object_Name);
       --  The procedure declaration entity for the argument
 
       Invariant_Found : Boolean;
@@ -3681,10 +3681,10 @@ package body Exp_Ch3 is
       begin
          Stmts := New_List;
          Decl := First_Non_Pragma (Component_Items (Comp_List));
-
          while Present (Decl) loop
             if Nkind (Decl) = N_Component_Declaration then
                Id  := Defining_Identifier (Decl);
+
                if Has_Invariants (Etype (Id)) then
                   Append_To (Stmts, Build_Component_Invariant_Call (Id));
                end if;
@@ -3734,14 +3734,16 @@ package body Exp_Ch3 is
          return Stmts;
       end Build_Invariant_Checks;
 
+   --  Start of processing for Build_Record_Invariant_Proc
+
    begin
       Invariant_Found := False;
       Type_Def := Type_Definition (Parent (R_Type));
+
       if Nkind (Type_Def) = N_Record_Definition
-        and then  not Null_Present (Type_Def)
+        and then not Null_Present (Type_Def)
       then
-         Stmts :=
-           Build_Invariant_Checks (Component_List (Type_Def));
+         Stmts := Build_Invariant_Checks (Component_List (Type_Def));
       else
          return;
       end if;
index 606587769e11adfdca070bfd4575542dc17152d3..03b275935b5e1080023ef31c207238017d02b977 100644 (file)
@@ -2660,8 +2660,7 @@ package body Freeze is
       --  storage of subprogram parameters.
 
       if Is_Subprogram (E)
-        and then (Check_Aliasing_Of_Parameters
-                    or else Check_Validity_Of_Parameters)
+        and then (Check_Aliasing_Of_Parameters or Check_Validity_Of_Parameters)
       then
          Apply_Parameter_Aliasing_And_Validity_Checks (E);
       end if;
index 311dad768204ace99eb84926a6608018a3906568..dc0d862c4dc172774eca4e8f4fd8087594d4b8b9 100644 (file)
@@ -326,7 +326,7 @@ package Opt is
    Check_Validity_Of_Parameters : Boolean := False;
    --  GNAT
    --  Set to True to check for proper scalar initialization of subprogram
-   --  parameters on both entry and exit.
+   --  parameters on both entry and exit. Turned on by??? turned off by???
 
    Check_Withs : Boolean := False;
    --  GNAT
index c93fd7e37f147199655641c5cef67ad806d38f18..c21468ffa2e4bba4e69fbfd91275aadd9105e885 100644 (file)
@@ -5232,16 +5232,16 @@ package body Sem_Ch13 is
    -- Build_Predicate_Function --
    ------------------------------
 
-   --  The procedure that is constructed here has the form
-
-   --  function typPredicate (Ixxx : typ) return Boolean is
-   --  begin
-   --     return
-   --        exp1 and then exp2 and then ...
-   --        and then typ1Predicate (typ1 (Ixxx))
-   --        and then typ2Predicate (typ2 (Ixxx))
-   --        and then ...;
-   --  end typPredicate;
+   --  The procedure that is constructed here has the form:
+
+   --    function typPredicate (Ixxx : typ) return Boolean is
+   --    begin
+   --       return
+   --          exp1 and then exp2 and then ...
+   --          and then typ1Predicate (typ1 (Ixxx))
+   --          and then typ2Predicate (typ2 (Ixxx))
+   --          and then ...;
+   --    end typPredicate;
 
    --  Here exp1, and exp2 are expressions from Predicate pragmas. Note that
    --  this is the point at which these expressions get analyzed, providing the
index c71c2db3eaa80071b39b6ef4fa565a8890029c47..5ace348d32508e9f5f04fa826bf19d1f9317ac21 100644 (file)
@@ -11344,9 +11344,7 @@ package body Sem_Ch6 is
          --  public subprogram, since we do get initializations to deal with.
          --  Other internally generated subprograms are not public.
 
-         if not Is_List_Member (DD)
-           and then Is_Init_Proc (DD)
-         then
+         if not Is_List_Member (DD) and then Is_Init_Proc (DD) then
             return True;
 
          elsif not Comes_From_Source (DD) then