From: Arnaud Charlet Date: Mon, 1 Oct 2012 08:45:43 +0000 (+0200) Subject: [multiple changes] X-Git-Tag: misc/gccgo-go1_1_2~532 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c5a26133df8575533bc97def6e76bf66bec7f91a;p=thirdparty%2Fgcc.git [multiple changes] 2012-10-01 Robert Dewar * freeze.adb, sem_ch6.adb, opt.ads, sem_ch13.adb, exp_ch3.adb: Minor reformatting. 2012-10-01 Hristian Kirtchev * checks.adb (Build_PPC_Pragma): A PPC pragma can now be properly associated with a subprogram body. From-SVN: r191902 --- diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index d0f86178e572..db3e9b826a08 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,13 @@ +2012-10-01 Robert Dewar + + * freeze.adb, sem_ch6.adb, opt.ads, sem_ch13.adb, + exp_ch3.adb: Minor reformatting. + +2012-10-01 Hristian Kirtchev + + * checks.adb (Build_PPC_Pragma): A PPC pragma can now be properly + associated with a subprogram body. + 2012-10-01 Ed Schonberg * aspects.ads: Type_Invariant'class is a valid aspect. diff --git a/gcc/ada/checks.adb b/gcc/ada/checks.adb index 885a5686c604..8d40abcb06e2 100644 --- a/gcc/ada/checks.adb +++ b/gcc/ada/checks.adb @@ -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. diff --git a/gcc/ada/exp_ch3.adb b/gcc/ada/exp_ch3.adb index 293c902389da..cf993757406d 100644 --- a/gcc/ada/exp_ch3.adb +++ b/gcc/ada/exp_ch3.adb @@ -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; diff --git a/gcc/ada/freeze.adb b/gcc/ada/freeze.adb index 606587769e11..03b275935b5e 100644 --- a/gcc/ada/freeze.adb +++ b/gcc/ada/freeze.adb @@ -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; diff --git a/gcc/ada/opt.ads b/gcc/ada/opt.ads index 311dad768204..dc0d862c4dc1 100644 --- a/gcc/ada/opt.ads +++ b/gcc/ada/opt.ads @@ -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 diff --git a/gcc/ada/sem_ch13.adb b/gcc/ada/sem_ch13.adb index c93fd7e37f14..c21468ffa2e4 100644 --- a/gcc/ada/sem_ch13.adb +++ b/gcc/ada/sem_ch13.adb @@ -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 diff --git a/gcc/ada/sem_ch6.adb b/gcc/ada/sem_ch6.adb index c71c2db3eaa8..5ace348d3250 100644 --- a/gcc/ada/sem_ch6.adb +++ b/gcc/ada/sem_ch6.adb @@ -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