From 0b3d16c08a9b4082e5b3fbfb82e282f49fe7ac1e Mon Sep 17 00:00:00 2001 From: Arnaud Charlet Date: Tue, 2 Aug 2011 16:02:45 +0200 Subject: [PATCH] [multiple changes] 2011-08-02 Thomas Quinot * s-taskin.ads: Minor reformatting. 2011-08-02 Emmanuel Briot * g-comlin.adb (Display_Help): swap the order in which it prints the short help and the general usage. 2011-08-02 Ed Schonberg * sem_ch12.adb (Analyze_Generic_Subprogram_Declaration): copy properly the aspect declarations and attach them to the generic copy for subsequent analysis. (Analyze_Subprogram_Instantiation): copy explicitly the aspect declarations of the generic tree to the new subprogram declarations. * sem_attr.adb (Check_Precondition_Postcondition): recognize conditions that apply to a subprogram instance. 2011-08-02 Robert Dewar * gnat_rm.texi: Clarify doc on pragma Source_File_Name[_Project]. 2011-08-02 Ed Schonberg * sem_ch3.adb (Derived_Type_Declaration): When checking that a untagged private type with a tagged full view is not derived in the immediate scope of the partial view, (RM 7.3 (7)) use the scope of the base type. From-SVN: r177157 --- gcc/ada/ChangeLog | 29 ++++++++++++++++++++++++ gcc/ada/g-comlin.adb | 8 +++---- gcc/ada/gnat_rm.texi | 11 ++++++--- gcc/ada/s-taskin.ads | 2 +- gcc/ada/sem_ch12.adb | 54 ++++++++++++++++++++++++++++++++++++++++---- gcc/ada/sem_ch3.adb | 20 +++++----------- gcc/ada/sem_prag.adb | 14 +++++++++++- 7 files changed, 111 insertions(+), 27 deletions(-) diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 71be8748ea8..b7d5737a4f7 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,32 @@ +2011-08-02 Thomas Quinot + + * s-taskin.ads: Minor reformatting. + +2011-08-02 Emmanuel Briot + + * g-comlin.adb (Display_Help): swap the order in which it prints the + short help and the general usage. + +2011-08-02 Ed Schonberg + + * sem_ch12.adb (Analyze_Generic_Subprogram_Declaration): copy properly + the aspect declarations and attach them to the generic copy for + subsequent analysis. + (Analyze_Subprogram_Instantiation): copy explicitly the aspect + declarations of the generic tree to the new subprogram declarations. + * sem_attr.adb (Check_Precondition_Postcondition): recognize + conditions that apply to a subprogram instance. + +2011-08-02 Robert Dewar + + * gnat_rm.texi: Clarify doc on pragma Source_File_Name[_Project]. + +2011-08-02 Ed Schonberg + + * sem_ch3.adb (Derived_Type_Declaration): When checking that a untagged + private type with a tagged full view is not derived in the immediate + scope of the partial view, (RM 7.3 (7)) use the scope of the base type. + 2011-08-02 Robert Dewar * exp_ch4.adb: Minor reformatting. diff --git a/gcc/ada/g-comlin.adb b/gcc/ada/g-comlin.adb index 217328e5d14..1963520cf79 100644 --- a/gcc/ada/g-comlin.adb +++ b/gcc/ada/g-comlin.adb @@ -3176,6 +3176,10 @@ package body GNAT.Command_Line is return; end if; + if Config.Help /= null and then Config.Help.all /= "" then + Put_Line (Config.Help.all); + end if; + if Config.Usage /= null then Put_Line ("Usage: " & Base_Name @@ -3185,10 +3189,6 @@ package body GNAT.Command_Line is & " [switches] [arguments]"); end if; - if Config.Help /= null and then Config.Help.all /= "" then - Put_Line (Config.Help.all); - end if; - Display_Section_Help (""); if Config.Sections /= null and then Config.Switches /= null then diff --git a/gcc/ada/gnat_rm.texi b/gcc/ada/gnat_rm.texi index ac0a7ee6d19..a2c86363973 100644 --- a/gcc/ada/gnat_rm.texi +++ b/gcc/ada/gnat_rm.texi @@ -4558,8 +4558,12 @@ specifies the casing of the unit name in the resulting file name string. The default is lower case. Finally the third argument allows for systematic replacement of any dots in the unit name by the specified string literal. -A pragma Source_File_Name cannot appear after a -@ref{Pragma Source_File_Name_Project}. +Note that Source_File_Name pragmas should not be used if you are using +project files. The reason for this rule is that the project manager is not +aware of these pragmas, and so other tools that use the projet file would not +be aware of the intended naming conventions. If you are using project files, +file naming is controlled by Source_File_Name_Project pragmas. A pragma +Source_File_Name cannot appear after a @ref{Pragma Source_File_Name_Project}. For more details on the use of the @code{Source_File_Name} pragma, @xref{Using Other File Names,,, gnat_ugn, @value{EDITION} User's Guide}, @@ -4581,7 +4585,8 @@ The intention is that Source_File_Name_Project pragmas are always generated by the Project Manager in a manner consistent with the naming specified in a project file, and when naming is controlled in this manner, it is not permissible to attempt to modify this naming scheme using -Source_File_Name pragmas (which would not be known to the project manager). +Source_File_Name or Source_File_Name_Project pragmas (which would not be +known to the project manager). @node Pragma Source_Reference @unnumberedsec Pragma Source_Reference diff --git a/gcc/ada/s-taskin.ads b/gcc/ada/s-taskin.ads index 4841d0b8b1d..074c86b6a4a 100644 --- a/gcc/ada/s-taskin.ads +++ b/gcc/ada/s-taskin.ads @@ -1057,7 +1057,7 @@ package System.Tasking is -- Protection: Self.L Serial_Number : Task_Serial_Number; - -- A growing number to provide some way to check locking rules/ordering + -- Monotonic counter to provide some way to check locking rules/ordering Known_Tasks_Index : Integer := -1; -- Index in the System.Tasking.Debug.Known_Tasks array diff --git a/gcc/ada/sem_ch12.adb b/gcc/ada/sem_ch12.adb index 3d0bc99d329..cfcd2963390 100644 --- a/gcc/ada/sem_ch12.adb +++ b/gcc/ada/sem_ch12.adb @@ -2794,6 +2794,20 @@ package body Sem_Ch12 is Set_Parent_Spec (New_N, Save_Parent); Rewrite (N, New_N); + -- The aspect specifications are not attached to the tree, and must + -- be copied and attached to the generic copy explicitly. + + if Present (Aspect_Specifications (New_N)) then + declare + Aspects : constant List_Id := Aspect_Specifications (N); + begin + Set_Has_Aspects (N, False); + Move_Aspects (New_N, N); + Set_Has_Aspects (Original_Node (N), False); + Set_Aspect_Specifications (Original_Node (N), Aspects); + end; + end if; + Spec := Specification (N); Id := Defining_Entity (Spec); Generate_Definition (Id); @@ -2888,16 +2902,42 @@ package body Sem_Ch12 is Save_Global_References (Original_Node (N)); + -- To capture global references, analyze the expressions of aspects, + -- and propagate information to original tree. Note that in this case + -- analysis of attributes is not delayed until the freeze point. + -- It seems very hard to recreate the proper visibility of the generic + -- subprogram at a later point because the analysis of an aspect may + -- create pragmas after the generic copies have been made ??? + + if Has_Aspects (N) then + declare + Aspect : Node_Id; + + begin + Aspect := First (Aspect_Specifications (N)); + while Present (Aspect) loop + if Get_Aspect_Id (Chars (Identifier (Aspect))) + /= Aspect_Warnings + then + Analyze (Expression (Aspect)); + end if; + Next (Aspect); + end loop; + + Aspect := First (Aspect_Specifications (Original_Node (N))); + while Present (Aspect) loop + Save_Global_References (Expression (Aspect)); + Next (Aspect); + end loop; + end; + end if; + End_Generic; End_Scope; Exit_Generic_Scope (Id); Generate_Reference_To_Formals (Id); List_Inherited_Pre_Post_Aspects (Id); - - if Has_Aspects (N) then - Analyze_Aspect_Specifications (N, Id); - end if; end Analyze_Generic_Subprogram_Declaration; ----------------------------------- @@ -4262,6 +4302,12 @@ package body Sem_Ch12 is Make_Subprogram_Declaration (Sloc (Act_Spec), Specification => Act_Spec); + -- The aspects have been copied previously, but they have to be + -- linked explicitly to the new subprogram declaration. + -- Explicit pre/postconditions on the instance are analyzed below, + -- in a separate step. + + Move_Aspects (Act_Tree, Act_Decl); Set_Categorization_From_Pragmas (Act_Decl); if Parent_Installed then diff --git a/gcc/ada/sem_ch3.adb b/gcc/ada/sem_ch3.adb index 458505211fe..ca160188bf6 100644 --- a/gcc/ada/sem_ch3.adb +++ b/gcc/ada/sem_ch3.adb @@ -13902,7 +13902,6 @@ package body Sem_Ch3 is Indic : constant Node_Id := Subtype_Indication (Def); Extension : constant Node_Id := Record_Extension_Part (Def); Parent_Node : Node_Id; - Parent_Scope : Entity_Id; Taggd : Boolean; -- Start of processing for Derived_Type_Declaration @@ -14225,25 +14224,18 @@ package body Sem_Ch3 is -- that it is not a Full_Type_Declaration (i.e. a private type or -- private extension declaration), to distinguish a partial view -- from a derivation from a private type which also appears as - -- E_Private_Type. + -- E_Private_Type. If the parent base type is not declared in an + -- enclosing scope there is no need to check. elsif Present (Full_View (Parent_Type)) and then Nkind (Parent (Parent_Type)) /= N_Full_Type_Declaration and then not Is_Tagged_Type (Parent_Type) and then Is_Tagged_Type (Full_View (Parent_Type)) + and then In_Open_Scopes (Scope (Base_Type (Parent_Type))) then - Parent_Scope := Scope (T); - while Present (Parent_Scope) - and then Parent_Scope /= Standard_Standard - loop - if Parent_Scope = Scope (Parent_Type) then - Error_Msg_N - ("premature derivation from type with tagged full view", - Indic); - end if; - - Parent_Scope := Scope (Parent_Scope); - end loop; + Error_Msg_N + ("premature derivation from type with tagged full view", + Indic); end if; end if; diff --git a/gcc/ada/sem_prag.adb b/gcc/ada/sem_prag.adb index 328c2f95a9b..3bacf904771 100644 --- a/gcc/ada/sem_prag.adb +++ b/gcc/ada/sem_prag.adb @@ -1738,7 +1738,18 @@ package body Sem_Prag is -- Skip stuff not coming from source elsif not Comes_From_Source (PO) then - null; + + -- The condition may apply to a subprogram instantiation. + + if Nkind (PO) = N_Subprogram_Declaration + and then Present (Generic_Parent (Specification (PO))) + then + Chain_PPC (PO); + return; + + else + null; + end if; -- Only remaining possibility is subprogram declaration @@ -7554,6 +7565,7 @@ package body Sem_Prag is then Set_Elaborate_Present (Citem, True); Set_Unit_Name (Get_Pragma_Arg (Arg), Name (Citem)); + Generate_Reference (Entity (Name (Citem)), Citem); -- With the pragma present, elaboration calls on -- subprograms from the named unit need no further -- 2.30.2