OSDN Git Service

2011-12-05 Bob Duff <duff@adacore.com>
authorcharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 5 Dec 2011 10:44:58 +0000 (10:44 +0000)
committercharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 5 Dec 2011 10:44:58 +0000 (10:44 +0000)
* sem_ch4.adb: Minor comment fix.

2011-12-05  Robert Dewar  <dewar@adacore.com>

* gnat_ugn.texi: Add documentation for -gnatw.e.

2011-12-05  Bob Duff  <duff@adacore.com>

* 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  <schonberg@adacore.com>

* lib-writ.adb (Output_Main_Program_Line): A generic subprogram
is never a main program.

2011-12-05  Thomas Quinot  <quinot@adacore.com>

* par_sco.adb: Various minor adjustments to dominance markers
generation.

2011-12-05  Ed Schonberg  <schonberg@adacore.com>

* 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.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@182006 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ada/ChangeLog
gcc/ada/gnat_ugn.texi
gcc/ada/lib-writ.adb
gcc/ada/par_sco.adb
gcc/ada/sem_ch4.adb
gcc/ada/sem_ch6.adb
gcc/ada/sem_util.adb
gcc/ada/treepr.adb

index d546da6..f9977b6 100644 (file)
@@ -1,5 +1,37 @@
 2011-12-05  Bob Duff  <duff@adacore.com>
 
+       * sem_ch4.adb: Minor comment fix.
+
+2011-12-05  Robert Dewar  <dewar@adacore.com>
+
+       * gnat_ugn.texi: Add documentation for -gnatw.e.
+
+2011-12-05  Bob Duff  <duff@adacore.com>
+
+       * 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  <schonberg@adacore.com>
+
+       * lib-writ.adb (Output_Main_Program_Line): A generic subprogram
+       is never a main program.
+
+2011-12-05  Thomas Quinot  <quinot@adacore.com>
+
+       * par_sco.adb: Various minor adjustments to dominance markers
+       generation.
+
+2011-12-05  Ed Schonberg  <schonberg@adacore.com>
+
+       * 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  <duff@adacore.com>
+
        * sem_ch3.adb (Derive_Progenitor_Subprograms): Add Ultimate_Alias
        to the Comes_From_Source check, to deal properly with the case
        of indirect inheritance of "=".
index 52198c6..d42ac09 100644 (file)
@@ -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.}
index 25c2559..2d67ea0 100644 (file)
@@ -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");
index cffb76b..4f3a36e 100644 (file)
@@ -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
-
-                     --  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);
+                     Inner_Dominant : Dominant_Info := No_Dominant;
+                  begin
+                     if Present (ISC) then
 
-                     declare
-                        ISC : constant Node_Id := Iteration_Scheme (N);
+                        --  If iteration scheme present, extend the current
+                        --  statement sequence to include the iteration scheme
+                        --  and process any decisions it contains.
 
-                     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;
 
    -------------------------------------
index 8f1e43a..197b575 100644 (file)
@@ -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.
index 903950d..2cc899e 100644 (file)
@@ -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);
 
index b38536f..8c90086 100644 (file)
@@ -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));
 
index c9411e1..684cccd 100644 (file)
@@ -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;