From 76264f602ae32ac6fea5e80ac0098d07b40fe4ab Mon Sep 17 00:00:00 2001 From: Arnaud Charlet Date: Mon, 5 Dec 2011 11:44:58 +0100 Subject: [PATCH] [multiple changes] 2011-12-05 Bob Duff * sem_ch4.adb: Minor comment fix. 2011-12-05 Robert Dewar * gnat_ugn.texi: Add documentation for -gnatw.e. 2011-12-05 Bob Duff * treepr.adb (pn): Print something useful for Elmt_Ids. Add Write_Eol to 'when others' case, so the output will be seen immediately in gdb. 2011-12-05 Ed Schonberg * lib-writ.adb (Output_Main_Program_Line): A generic subprogram is never a main program. 2011-12-05 Thomas Quinot * par_sco.adb: Various minor adjustments to dominance markers generation. 2011-12-05 Ed Schonberg * sem_ch6.adb (Analyze_Expression_Function): If the function is a completion, generate a body reference for its defining entity, before rewriting the node as a body. * sem_util.adb (Defining_Entity): Add entry for expression function. From-SVN: r182006 --- gcc/ada/ChangeLog | 32 +++++++++++++ gcc/ada/gnat_ugn.texi | 7 ++- gcc/ada/lib-writ.adb | 12 ++++- gcc/ada/par_sco.adb | 105 ++++++++++++++++++++++++++++-------------- gcc/ada/sem_ch4.adb | 2 +- gcc/ada/sem_ch6.adb | 4 ++ gcc/ada/sem_util.adb | 3 +- gcc/ada/treepr.adb | 13 +++++- 8 files changed, 138 insertions(+), 40 deletions(-) diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index d546da6d816..f9977b6a37a 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,35 @@ +2011-12-05 Bob Duff + + * sem_ch4.adb: Minor comment fix. + +2011-12-05 Robert Dewar + + * gnat_ugn.texi: Add documentation for -gnatw.e. + +2011-12-05 Bob Duff + + * treepr.adb (pn): Print something useful for + Elmt_Ids. Add Write_Eol to 'when others' case, so the output + will be seen immediately in gdb. + +2011-12-05 Ed Schonberg + + * lib-writ.adb (Output_Main_Program_Line): A generic subprogram + is never a main program. + +2011-12-05 Thomas Quinot + + * par_sco.adb: Various minor adjustments to dominance markers + generation. + +2011-12-05 Ed Schonberg + + * sem_ch6.adb (Analyze_Expression_Function): If the function is + a completion, generate a body reference for its defining entity, + before rewriting the node as a body. + * sem_util.adb (Defining_Entity): Add entry for expression + function. + 2011-12-05 Bob Duff * sem_ch3.adb (Derive_Progenitor_Subprograms): Add Ultimate_Alias diff --git a/gcc/ada/gnat_ugn.texi b/gcc/ada/gnat_ugn.texi index 52198c6b7d7..d42ac09cfc7 100644 --- a/gcc/ada/gnat_ugn.texi +++ b/gcc/ada/gnat_ugn.texi @@ -5242,7 +5242,12 @@ is the only -gnatw switch that affects the handling of style check messages. @cindex @option{-gnatw.e} (@command{gcc}) @cindex Warnings, activate every optional warning This switch activates all optional warnings, including those which -are not activated by @code{-gnatwa}. +are not activated by @code{-gnatwa}. The use of this switch is not +recommended for normal use. If you turn this switch on, it is almost +certain that you will get large numbers of useless warnings. The +warnings that are excluded from @code{-gnatwa} are typically highly +specialized warnings that are suitable for use only in code that has +been specifically designed according to specialized coding rules. @item -gnatwf @emph{Activate warnings on unreferenced formals.} diff --git a/gcc/ada/lib-writ.adb b/gcc/ada/lib-writ.adb index 25c2559e559..2d67ea03ccd 100644 --- a/gcc/ada/lib-writ.adb +++ b/gcc/ada/lib-writ.adb @@ -987,7 +987,17 @@ package body Lib.Writ is S := Specification (U); - if No (Parameter_Specifications (S)) then + -- A generic subprogram is never a main program + + if Nkind (U) = N_Subprogram_Body + and then Present (Corresponding_Spec (U)) + and then + Ekind_In (Corresponding_Spec (U), + E_Generic_Procedure, E_Generic_Function) + then + null; + + elsif No (Parameter_Specifications (S)) then if Nkind (S) = N_Procedure_Specification then Write_Info_Initiate ('M'); Write_Info_Str (" P"); diff --git a/gcc/ada/par_sco.adb b/gcc/ada/par_sco.adb index cffb76beae8..4f3a36e37eb 100644 --- a/gcc/ada/par_sco.adb +++ b/gcc/ada/par_sco.adb @@ -149,7 +149,9 @@ package body Par_SCO is procedure Traverse_Package_Body (N : Node_Id); procedure Traverse_Package_Declaration (N : Node_Id); procedure Traverse_Protected_Body (N : Node_Id); - procedure Traverse_Subprogram_Or_Task_Body (N : Node_Id); + procedure Traverse_Subprogram_Or_Task_Body + (N : Node_Id; + D : Dominant_Info := No_Dominant); procedure Traverse_Subprogram_Declaration (N : Node_Id); -- Traverse the corresponding construct, generating SCO table entries @@ -1039,8 +1041,8 @@ package body Par_SCO is Current_Dominant : Dominant_Info := D; -- Dominance information for the current basic block - Current_Condition : Node_Id; - -- Last tested condition in current IF statement + Current_Test : Node_Id; + -- Conditional node (N_If_Statement or N_Elsiif being processed N : Node_Id; Dummy : Source_Ptr; @@ -1273,15 +1275,20 @@ package body Par_SCO is declare Cond : constant Node_Id := Condition (Entry_Body_Formal_Part (N)); - + Inner_Dominant : Dominant_Info := No_Dominant; begin Set_Statement_Entry; if Present (Cond) then Process_Decisions_Defer (Cond, 'G'); + + -- For an entry body with a barrier, the entry body + -- is dominanted by a True evaluation of the barrier. + + Inner_Dominant := ('T', N); end if; - Traverse_Subprogram_Or_Task_Body (N); + Traverse_Subprogram_Or_Task_Body (N, Inner_Dominant); end; -- Protected body @@ -1299,7 +1306,15 @@ package body Par_SCO is Extend_Statement_Sequence (N, ' '); Process_Decisions_Defer (Condition (N), 'E'); Set_Statement_Entry; - Current_Dominant := No_Dominant; + + -- If condition is present, then following statement is + -- only executed if the condition evaluates to False. + + if Present (Condition (N)) then + Current_Dominant := ('F', N); + else + Current_Dominant := No_Dominant; + end if; -- Label, which breaks the current statement sequence, but the -- label itself is not included in the next statement sequence, @@ -1324,41 +1339,57 @@ package body Par_SCO is -- but we include the condition in the current sequence. when N_If_Statement => - Current_Condition := Condition (N); - Extend_Statement_Sequence (N, Current_Condition, 'I'); - Process_Decisions_Defer (Current_Condition, 'I'); + Current_Test := N; + Extend_Statement_Sequence (N, Condition (N), 'I'); + Process_Decisions_Defer (Condition (N), 'I'); Set_Statement_Entry; -- Now we traverse the statements in the THEN part Traverse_Declarations_Or_Statements (L => Then_Statements (N), - D => ('T', Current_Condition)); + D => ('T', N)); -- Loop through ELSIF parts if present if Present (Elsif_Parts (N)) then declare + Saved_Dominant : constant Dominant_Info := + Current_Dominant; Elif : Node_Id := First (Elsif_Parts (N)); begin while Present (Elif) loop + -- An Elsif is executed only if the previous test + -- got a FALSE outcome. + + Current_Dominant := ('F', Current_Test); + + -- Now update current test information + + Current_Test := Elif; + -- We generate a statement sequence for the -- construct "ELSIF condition", so that we have -- a statement for the resulting decisions. - Current_Condition := Condition (Elif); Extend_Statement_Sequence - (Elif, Current_Condition, 'I'); - Process_Decisions_Defer (Current_Condition, 'I'); + (Elif, Condition (Elif), 'I'); + Process_Decisions_Defer (Condition (Elif), 'I'); Set_Statement_Entry; + -- An ELSIF part is never guaranteed to have + -- been executed, following statements are only + -- dominated by the initial IF statement. + + Current_Dominant := Saved_Dominant; + -- Traverse the statements in the ELSIF Traverse_Declarations_Or_Statements (L => Then_Statements (Elif), - D => ('T', Current_Condition)); + D => ('T', Elif)); Next (Elif); end loop; end; @@ -1368,7 +1399,7 @@ package body Par_SCO is Traverse_Declarations_Or_Statements (L => Else_Statements (N), - D => ('F', Current_Condition)); + D => ('F', Current_Test)); -- Case statement, which breaks the current statement sequence, -- but we include the expression in the current sequence. @@ -1433,16 +1464,16 @@ package body Par_SCO is -- may not be executed as part of the current sequence. when N_Loop_Statement => - if Present (Iteration_Scheme (N)) then + declare + ISC : constant Node_Id := Iteration_Scheme (N); + Inner_Dominant : Dominant_Info := No_Dominant; + begin + if Present (ISC) then - -- If iteration scheme present, extend the current - -- statement sequence to include the iteration scheme - -- and process any decisions it contains. + -- If iteration scheme present, extend the current + -- statement sequence to include the iteration scheme + -- and process any decisions it contains. - declare - ISC : constant Node_Id := Iteration_Scheme (N); - - begin -- While statement if Present (Condition (ISC)) then @@ -1451,7 +1482,7 @@ package body Par_SCO is -- Set more specific dominant for inner statements - Current_Dominant := ('T', Condition (ISC)); + Inner_Dominant := ('T', N); -- For statement @@ -1460,17 +1491,18 @@ package body Par_SCO is Process_Decisions_Defer (Loop_Parameter_Specification (ISC), 'X'); end if; - end; - end if; + end if; - Set_Statement_Entry; - Traverse_Declarations_Or_Statements - (L => Statements (N), - D => Current_Dominant); + Set_Statement_Entry; - -- Reset current dominant + if Inner_Dominant = No_Dominant then + Inner_Dominant := Current_Dominant; + end if; - Current_Dominant := ('S', N); + Traverse_Declarations_Or_Statements + (L => Statements (N), + D => Inner_Dominant); + end; -- Pragma @@ -1708,10 +1740,13 @@ package body Par_SCO is -- Traverse_Subprogram_Or_Task_Body -- -------------------------------------- - procedure Traverse_Subprogram_Or_Task_Body (N : Node_Id) is + procedure Traverse_Subprogram_Or_Task_Body + (N : Node_Id; + D : Dominant_Info := No_Dominant) + is begin - Traverse_Declarations_Or_Statements (Declarations (N)); - Traverse_Handled_Statement_Sequence (Handled_Statement_Sequence (N)); + Traverse_Declarations_Or_Statements (Declarations (N), D); + Traverse_Handled_Statement_Sequence (Handled_Statement_Sequence (N), D); end Traverse_Subprogram_Or_Task_Body; ------------------------------------- diff --git a/gcc/ada/sem_ch4.adb b/gcc/ada/sem_ch4.adb index 8f1e43a56b4..197b5757d4b 100644 --- a/gcc/ada/sem_ch4.adb +++ b/gcc/ada/sem_ch4.adb @@ -6233,7 +6233,7 @@ package body Sem_Ch4 is Remove_Interp (I); exit; - -- In Ada 2005, this operation does not participate in Overload + -- In Ada 2005, this operation does not participate in overload -- resolution. If the operation is defined in a predefined -- unit, it is one of the operations declared abstract in some -- variants of System, and it must be removed as well. diff --git a/gcc/ada/sem_ch6.adb b/gcc/ada/sem_ch6.adb index 903950d8f8d..2cc899e934a 100644 --- a/gcc/ada/sem_ch6.adb +++ b/gcc/ada/sem_ch6.adb @@ -331,6 +331,10 @@ package body Sem_Ch6 is and then Comes_From_Source (Prev) then Set_Has_Completion (Prev, False); + + -- For navigation purposes, indicate that the function is a body + + Generate_Reference (Prev, Defining_Entity (N), 'b', Force => True); Rewrite (N, New_Body); Analyze (N); diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb index b38536fb535..8c90086d9a0 100644 --- a/gcc/ada/sem_util.adb +++ b/gcc/ada/sem_util.adb @@ -2467,7 +2467,8 @@ package body Sem_Util is N_Subprogram_Body_Stub | N_Generic_Subprogram_Declaration | N_Generic_Package_Declaration | - N_Formal_Subprogram_Declaration + N_Formal_Subprogram_Declaration | + N_Expression_Function => return Defining_Entity (Specification (N)); diff --git a/gcc/ada/treepr.adb b/gcc/ada/treepr.adb index c9411e13e38..684cccdcc19 100644 --- a/gcc/ada/treepr.adb +++ b/gcc/ada/treepr.adb @@ -273,7 +273,17 @@ package body Treepr is when Elist_Range => Print_Tree_Elist (Elist_Id (N)); when Elmt_Range => - raise Program_Error; + declare + Id : constant Elmt_Id := Elmt_Id (N); + begin + if No (Id) then + Write_Str ("No_Elmt"); + Write_Eol; + else + Write_Str ("Elmt_Id --> "); + Print_Tree_Node (Node (Id)); + end if; + end; when Names_Range => Namet.wn (Name_Id (N)); when Strings_Range => @@ -285,6 +295,7 @@ package body Treepr is when others => Write_Str ("Invalid Union_Id: "); Write_Int (Int (N)); + Write_Eol; end case; end pn;