[multiple changes]
authorArnaud Charlet <charlet@gcc.gnu.org>
Wed, 5 Dec 2012 10:50:26 +0000 (11:50 +0100)
committerArnaud Charlet <charlet@gcc.gnu.org>
Wed, 5 Dec 2012 10:50:26 +0000 (11:50 +0100)
2012-12-05  Robert Dewar  <dewar@adacore.com>

* gnatchop.adb, sem_attr.ads, sem_ch4.adb, sem_ch6.adb, exp_disp.adb,
atree.adb, sem_eval.adb: Minor reformatting.

2012-12-05  Yannick Moy  <moy@adacore.com>

* uintp.adb (UI_Div_Rem): Correct algorithm D to remove potential
overflow.

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

* exp_ch4.adb (Expand_N_Op_Mod): Minor comment additions.
(Expand_N_Op_Rem): Ditto.

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

* sem_attr.adb: Minor reformatting.

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

* usage.adb: Update lines for -gnato? switch.

From-SVN: r194202

12 files changed:
gcc/ada/ChangeLog
gcc/ada/atree.adb
gcc/ada/exp_ch4.adb
gcc/ada/exp_disp.adb
gcc/ada/gnatchop.adb
gcc/ada/sem_attr.adb
gcc/ada/sem_attr.ads
gcc/ada/sem_ch4.adb
gcc/ada/sem_ch6.adb
gcc/ada/sem_eval.adb
gcc/ada/uintp.adb
gcc/ada/usage.adb

index b7da722bfc05870f9540f0bccfeaa8095900b188..1fb42a70c71da5a1742c0bfbf749f6abee557aba 100644 (file)
@@ -1,3 +1,26 @@
+2012-12-05  Robert Dewar  <dewar@adacore.com>
+
+       * gnatchop.adb, sem_attr.ads, sem_ch4.adb, sem_ch6.adb, exp_disp.adb,
+       atree.adb, sem_eval.adb: Minor reformatting.
+
+2012-12-05  Yannick Moy  <moy@adacore.com>
+
+       * uintp.adb (UI_Div_Rem): Correct algorithm D to remove potential
+       overflow.
+
+2012-12-05  Robert Dewar  <dewar@adacore.com>
+
+       * exp_ch4.adb (Expand_N_Op_Mod): Minor comment additions.
+       (Expand_N_Op_Rem): Ditto.
+
+2012-12-05  Robert Dewar  <dewar@adacore.com>
+
+       * sem_attr.adb: Minor reformatting.
+
+2012-12-05  Robert Dewar  <dewar@adacore.com>
+
+       * usage.adb: Update lines for -gnato? switch.
+
 2012-12-05  Ed Schonberg  <schonberg@adacore.com>
 
        * par-ch6.adb (P_Return_Object_Declaration): Do not check for
index 70dd3801e5cdef99ec4ff7d4cf477a4f0764a527..d51e85d300cbded8ff417477f3e1e4b60287fa19 100644 (file)
@@ -1931,6 +1931,7 @@ package body Atree is
             if Is_Syntactic_Field (Nkind (Nod), FN) then
                declare
                   Elmt : Node_Id := First (List_Id (Fld));
+
                begin
                   while Present (Elmt) loop
                      if Traverse_Func (Elmt) = Abandon then
index 80c27c4e994a719dc1ec9972cfefee7c8646e95f..b3701bcdfcb32648f2a4a7a13a7471c294dd5955 100644 (file)
@@ -8001,8 +8001,15 @@ package body Exp_Ch4 is
          end if;
 
          --  Deal with annoying case of largest negative number remainder
-         --  minus one. Gigi does not handle this case correctly, because
-         --  it generates a divide instruction which may trap in this case.
+         --  minus one. Gigi may not handle this case correctly, because
+         --  on some targets, the mod value is computed using a divide
+         --  instruction which gives an overflow trap for this case.
+
+         --  It would be a bit more efficient to figure out which targets
+         --  this is really needed for, but in practice it is reasonable
+         --  to do the following special check in all cases, since it means
+         --  we get a clearer message, and also the overhead is minimal given
+         --  that division is expensive in any case.
 
          --  In fact the check is quite easy, if the right operand is -1, then
          --  the mod value is always 0, and we can just ignore the left operand
@@ -8674,8 +8681,15 @@ package body Exp_Ch4 is
       end if;
 
       --  Deal with annoying case of largest negative number remainder minus
-      --  one. Gigi does not handle this case correctly, because it generates
-      --  a divide instruction which may trap in this case.
+      --  one. Gigi may not handle this case correctly, because on some
+      --  targets, the mod value is computed using a divide instruction
+      --  which gives an overflow trap for this case.
+
+      --  It would be a bit more efficient to figure out which targets this
+      --  is really needed for, but in practice it is reasonable to do the
+      --  following special check in all cases, since it means we get a clearer
+      --  message, and also the overhead is minimal given that division is
+      --  expensive in any case.
 
       --  In fact the check is quite easy, if the right operand is -1, then
       --  the remainder is always 0, and we can just ignore the left operand
index 8706b9e64563eafbd7aff39fd5df92932c617e42..23235d8db51a68feffb658fdebf13c884590fced 100644 (file)
@@ -1635,15 +1635,15 @@ package body Exp_Disp is
       Formals : constant List_Id    := New_List;
       Target  : constant Entity_Id  := Ultimate_Alias (Prim);
 
-      Decl_1          : Node_Id;
-      Decl_2          : Node_Id;
-      Expr            : Node_Id;
-      Formal          : Node_Id;
-      Ftyp            : Entity_Id;
-      Iface_Formal    : Node_Id;
-      New_Arg         : Node_Id;
-      Offset_To_Top   : Node_Id;
-      Target_Formal   : Entity_Id;
+      Decl_1        : Node_Id;
+      Decl_2        : Node_Id;
+      Expr          : Node_Id;
+      Formal        : Node_Id;
+      Ftyp          : Entity_Id;
+      Iface_Formal  : Node_Id;
+      New_Arg       : Node_Id;
+      Offset_To_Top : Node_Id;
+      Target_Formal : Entity_Id;
 
    begin
       Thunk_Id   := Empty;
index 0969c53135c9f8f2793f2683b698d1cc90967573..82b944b78c572c23a5d730c9f75da05996620c27 100644 (file)
@@ -1021,6 +1021,10 @@ procedure Gnatchop is
 
       Buffer (Read_Ptr) := EOF;
 
+      --  Comment needed for the following ???
+      --  Under what circumstances can the test fail ???
+      --  What is copy doing in that case???
+
       if Read_Ptr = Length then
          Contents := Buffer;
 
index 773b50205e69572ed1a586e53d173d600be3de5a..b68b5937c38dcb3d6bef9ec866acee82687fcf4a 100644 (file)
@@ -5998,8 +5998,7 @@ package body Sem_Attr is
          return
            Is_Floating_Point_Type (Typ)
              and then
-               (Float_Format = 'V'
-                  or else Float_Rep (Typ) = VAX_Native);
+               (Float_Format = 'V' or else Float_Rep (Typ) = VAX_Native);
       end Is_VAX_Float;
 
       --------------
index b993b9bab82638486de27382fa09ad06171bc738..7583ab434f4f1faaddb5e179833d5b685b126469 100644 (file)
@@ -313,7 +313,7 @@ package Sem_Attr is
       --  needed, and the value should never be accessed.
 
       Attribute_Loop_Entry => True,
-      --  For every object of a non-limited type, S'Loop_Entry { (Loop_Name) }
+      --  For every object of a non-limited type, S'Loop_Entry [(Loop_Name)]
       --  denotes the constant value of prefix S at the point of entry into the
       --  related loop. The type of the attribute is the type of the prefix.
 
index 2c54fcdc5c8882996b930484e7dceca41f761da9..55051417c89992d990048122edc07d66ac8ebd5d 100644 (file)
@@ -5506,6 +5506,12 @@ package body Sem_Ch4 is
    begin
       if T1 = Universal_Integer
         or else T1 = Universal_Real
+
+        --  If the left operand of an equality operator is null, the visibility
+        --  of the operator must be determined from the interpretation of the
+        --  right operand. This processing must be done for Any_Access, which
+        --  is the internal representation of the type of the literal null.
+
         or else T1 = Any_Access
       then
          if not Is_Overloaded (R) then
index cfa709cd9d266e4916c84e131294af3adaaf94c3..2903e896e5ebebe263340b44e837e9e2c8bccdc2 100644 (file)
@@ -787,7 +787,6 @@ package body Sem_Ch6 is
 
             Analyze_And_Resolve (Expr, R_Type);
             Check_Limited_Return (Expr);
-
          end if;
 
          --  RETURN only allowed in SPARK as the last statement in function
@@ -808,10 +807,9 @@ package body Sem_Ch6 is
 
          declare
             Obj_Decl    : constant Node_Id :=
-                         Last (Return_Object_Declarations (N));
+                            Last (Return_Object_Declarations (N));
             Has_Aliased : constant Boolean := Aliased_Present (Obj_Decl);
-
-            HSS : constant Node_Id := Handled_Statement_Sequence (N);
+            HSS         : constant Node_Id := Handled_Statement_Sequence (N);
 
          begin
             Expr := Expression (Obj_Decl);
index 4a8fa2c627f8d4f33ef98af185adab6889f48150..a4bb76e309b9620f35479f0ed9901ff9acb07713 100644 (file)
@@ -1314,13 +1314,14 @@ package body Sem_Eval is
       --  is at optimizing and knowing that things are constant when they are
       --  nonstatic.
 
-      --  We make an exception for expressions that evaluate to True/False, to
-      --  suppress spurious checks in ZFP mode.
-
       if Configurable_Run_Time_Mode
         and then K /= N_Null
         and then not Is_Static_Expression (Op)
       then
+         --  We make an exception for expressions that evaluate to True/False,
+         --  to suppress spurious checks in ZFP mode. So far we have not seen
+         --  any negative consequences of this exception.
+
          if Is_Entity_Name (Op)
            and then Ekind (Entity (Op)) = E_Enumeration_Literal
            and then Etype (Entity (Op)) = Standard_Boolean
index 0761f2df70b12c0e222f9eed299c83144c6f942f..bc014666224fba9c5caf93c3279a50aec14c7926 100644 (file)
@@ -1165,6 +1165,7 @@ package body Uintp is
             Divisor_Dig1 : Int;
             Divisor_Dig2 : Int;
             Q_Guess      : Int;
+            R_Guess      : Int;
 
          begin
             --  [ NORMALIZE ] (step D1 in the algorithm). First calculate the
@@ -1218,30 +1219,26 @@ package body Uintp is
 
                --  Note: this version of step D3 is from the original published
                --  algorithm, which is known to have a bug causing overflows.
-               --  See: http://www-cs-faculty.stanford.edu/~uno/err2-2e.ps.gz.
-               --  In this code we are safe since our representation of double
-               --  length numbers allows an expanded range.
-
-               --  We don't have a proof of this claim, but the only cases we
-               --  have found that show the bug in step D3 work fine here.
+               --  See: http://www-cs-faculty.stanford.edu/~uno/err2-2e.ps.gz
+               --  and http://www-cs-faculty.stanford.edu/~uno/all2-pre.ps.gz.
+               --  The code below is the fixed version of this step.
 
                Tmp_Int := Dividend (J) * Base + Dividend (J + 1);
 
                --  Initial guess
 
-               if Dividend (J) = Divisor_Dig1 then
-                  Q_Guess := Base - 1;
-               else
-                  Q_Guess := Tmp_Int / Divisor_Dig1;
-               end if;
+               Q_Guess := Tmp_Int / Divisor_Dig1;
+               R_Guess := Tmp_Int rem Divisor_Dig1;
 
                --  Refine the guess
 
-               while Divisor_Dig2 * Q_Guess >
-                     (Tmp_Int - Q_Guess * Divisor_Dig1) * Base +
-                        Dividend (J + 2)
+               while Q_Guess >= Base
+                 or else Divisor_Dig2 * Q_Guess >
+                           R_Guess * Base + Dividend (J + 2)
                loop
                   Q_Guess := Q_Guess - 1;
+                  R_Guess := R_Guess + Divisor_Dig1;
+                  exit when R_Guess >= Base;
                end loop;
 
                --  [ MULTIPLY & SUBTRACT ] (step D4). Q_Guess * Divisor is
index 7c9c4023bbe92fe68a80b5d06fdb1643d1707fe2..c492ecfea65ca6869c5106d5c0c02a90361e1c28 100644 (file)
@@ -321,13 +321,14 @@ begin
    Write_Switch_Char ("o");
    Write_Line ("Enable overflow checking mode to CHECKED (off by default)");
 
-   --  Line for -gnato? switch
+   --  Lines for -gnato? switches
 
    Write_Switch_Char ("o?");
-   Write_Line ("Set SUPPRESSED/CHECKED/MINIMIZED/ELIMINATED (?=0/1/2/3) mode");
-
+   Write_Line
+     ("Enable overflow checks in STRICT/MINIMIZED/ELIMINATED (1/2/3) mode ");
    Write_Switch_Char ("o??");
-   Write_Line ("Set mode for general/assertion expressions separately");
+   Write_Line
+     ("Set mode for general/assertion expressions separately");
 
    --  Line for -gnatO switch
 
@@ -366,22 +367,22 @@ begin
    Write_Switch_Char ("R?s");
    Write_Line ("List rep info to file.rep instead of standard output");
 
-   --  Lines for -gnats switch
+   --  Line for -gnats switch
 
    Write_Switch_Char ("s");
    Write_Line ("Syntax check only");
 
-   --  Lines for -gnatS switch
+   --  Line for -gnatS switch
 
    Write_Switch_Char ("S");
    Write_Line ("Print listing of package Standard");
 
-   --  Lines for -gnatt switch
+   --  Line for -gnatt switch
 
    Write_Switch_Char ("t");
    Write_Line ("Tree output file to be generated");
 
-   --  Line for -gnatT switch
+   --  Line for -gnatTnn switch
 
    Write_Switch_Char ("Tnn");
    Write_Line ("All compiler tables start at nn times usual starting size");
@@ -401,7 +402,7 @@ begin
    Write_Switch_Char ("v");
    Write_Line ("Verbose mode. Full error output with source lines to stdout");
 
-   --  Line for -gnatV switch
+   --  Lines for -gnatV switch
 
    Write_Switch_Char ("Vxx");
    Write_Line