[multiple changes]
authorArnaud Charlet <charlet@gcc.gnu.org>
Tue, 20 Dec 2011 14:04:19 +0000 (15:04 +0100)
committerArnaud Charlet <charlet@gcc.gnu.org>
Tue, 20 Dec 2011 14:04:19 +0000 (15:04 +0100)
2011-12-20  Bob Duff  <duff@adacore.com>

* opt.ads (List_Inherited_Aspects): Default to False
(i.e. -gnatw.L is the default).
* usage.adb: Document new default for -gnatw.L.
* gnat_ugn.texi: Document -gnatw.l and -gnatw.L switches.
* warnsw.adb (Set_Warning_Switch): Do not include
List_Inherited_Aspects in -gnatwa.

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

* checks.adb (Apply_Type_Conversion_Checks): For a discrete type
with predicates, indicate unconditionally that a range check
is needed.
* exp_ch4.adb (Expand_N_In): When the membership test is rewritten
to incorporate a call to a predicate function, analyze expression
with checks suppressed, to prevent infinite recursion.

From-SVN: r182540

gcc/ada/ChangeLog
gcc/ada/checks.adb
gcc/ada/exp_ch4.adb
gcc/ada/gnat_ugn.texi
gcc/ada/opt.ads
gcc/ada/usage.adb
gcc/ada/warnsw.adb

index 697ea3dbba2e367bdf60b2dc4739caa5a3f79421..6502681a7327dd7fc1e58f290365aea4b0896907 100644 (file)
@@ -1,3 +1,21 @@
+2011-12-20  Bob Duff  <duff@adacore.com>
+
+       * opt.ads (List_Inherited_Aspects): Default to False
+       (i.e. -gnatw.L is the default).
+       * usage.adb: Document new default for -gnatw.L.
+       * gnat_ugn.texi: Document -gnatw.l and -gnatw.L switches.
+       * warnsw.adb (Set_Warning_Switch): Do not include
+       List_Inherited_Aspects in -gnatwa.
+
+2011-12-20  Ed Schonberg  <schonberg@adacore.com>
+
+       * checks.adb (Apply_Type_Conversion_Checks): For a discrete type
+       with predicates, indicate unconditionally that a range check
+       is needed.
+       * exp_ch4.adb (Expand_N_In): When the membership test is rewritten
+       to incorporate a call to a predicate function, analyze expression
+       with checks suppressed, to prevent infinite recursion.
+
 2011-12-20  Hristian Kirtchev  <kirtchev@adacore.com>
 
        * exp_ch11.adb (Find_Local_Handler): Guard the
index 5383bd8299cb1eef0bc1e1bbb795ebe4620e86f8..059253fd903be9d8aa053572b868761caef8b842 100644 (file)
@@ -2398,6 +2398,15 @@ package body Checks is
                else
                   Apply_Scalar_Range_Check
                     (Expr, Target_Type, Fixed_Int => Conv_OK);
+
+                  --  If the target type has predicates, we need to indicate
+                  --  the need for a check, even if Determine_Range finds
+                  --  that the value is within bounds. This may be the case
+                  --  e.g for a division with a constant denominator.
+
+                  if Has_Predicates (Target_Type) then
+                     Enable_Range_Check (Expr);
+                  end if;
                end if;
             end if;
          end;
index f45ea08bdf952a4b005cc3f98fd299a9e92b8016..8082cb0c24148f3ab29df780b297b93123fd3df4 100644 (file)
@@ -5228,10 +5228,11 @@ package body Exp_Ch4 is
                 Right_Opnd => Make_Predicate_Call (Rtyp, Lop)));
 
             --  Analyze new expression, mark left operand as analyzed to
-            --  avoid infinite recursion adding predicate calls.
+            --  avoid infinite recursion adding predicate calls. Similarly,
+            --  suppress further range checks on the call.
 
             Set_Analyzed (Left_Opnd (N));
-            Analyze_And_Resolve (N, Standard_Boolean);
+            Analyze_And_Resolve (N, Standard_Boolean, Suppress => All_Checks);
 
             --  All done, skip attempt at compile time determination of result
 
index d42ac09cfc7540067918c85dfa4585868a56d02b..92aba09596df4711ec235637f138fd8711534ee4 100644 (file)
@@ -5093,6 +5093,7 @@ switch are
 @option{-gnatwh} (hiding),
 @option{-gnatw.h} (holes (gaps) in record layouts)
 @option{-gnatwl} (elaboration warnings),
+@option{-gnatw.l} (inherited aspects),
 @option{-gnatw.o} (warn on values set by out parameters ignored)
 and @option{-gnatwt} (tracking of deleted conditional code).
 All other optional warnings are turned on.
@@ -5424,6 +5425,19 @@ This switch suppresses warnings on missing Elaborate and Elaborate_All pragmas.
 See the section in this guide on elaboration checking for details on
 when such pragmas should be used.
 
+@item -gnatw.l
+@emph{List inherited aspects.}
+@cindex @option{-gnatw.l} (@command{gcc})
+This switch causes the compiler to list inherited invariants,
+preconditions, and postconditions from Invariant'Class, Pre'Class, and
+Post'Class aspects. Also list inherited subtype predicates.
+These messages are not automatically turned on by the use of @option{-gnatwa}.
+
+@item -gnatw.L
+@emph{Suppress listing of inherited aspects.}
+@cindex @option{-gnatw.L} (@command{gcc})
+This switch suppresses listing of inherited aspects.
+
 @item -gnatwm
 @emph{Activate warnings on modified but unreferenced variables.}
 @cindex @option{-gnatwm} (@command{gcc})
index 4c1f5609318c4fc697fdf4e8bd2b7ec94ddd2b95..555283c62780434556c62915fc5eaa5860d38e39 100644 (file)
@@ -801,10 +801,12 @@ package Opt is
    --  Set to True to skip compile and bind steps (except when Bind_Only is
    --  set to True).
 
-   List_Inherited_Aspects : Boolean := True;
+   List_Inherited_Aspects : Boolean := False;
    --  GNAT
    --  List inherited invariants, preconditions, and postconditions from
-   --  Invariant'Class, Pre'Class, and Post'Class aspects.
+   --  Invariant'Class, Pre'Class, and Post'Class aspects. Also list inherited
+   --  subtype predicates. Set True by use of -gnatw.l and False by use of
+   --  -gnatw.L.
 
    List_Restrictions : Boolean := False;
    --  GNATBIND
index aa4b8156906f84cfc231f697863cc572dac11cc3..c4e7176875b7cf347c9839f147e01710fd71537f 100644 (file)
@@ -453,8 +453,8 @@ begin
                                                   "elaboration pragma");
    Write_Line ("        L*   turn off warnings for missing " &
                                                   "elaboration pragma");
-   Write_Line ("        .l*  turn on info messages for inherited aspects");
-   Write_Line ("        .L   turn off info messages for inherited aspects");
+   Write_Line ("        .l   turn on info messages for inherited aspects");
+   Write_Line ("        .L*   turn off info messages for inherited aspects");
    Write_Line ("        m+   turn on warnings for variable assigned " &
                                                   "but not read");
    Write_Line ("        M*   turn off warnings for variable assigned " &
index 703ce0c257edb49842425b8a6b2ecca095bcbf16..3c5776758ca9e8111a4d4b3c5e2585578d58212b 100644 (file)
@@ -251,7 +251,6 @@ package body Warnsw is
             Constant_Condition_Warnings         := True;
             Implementation_Unit_Warnings        := True;
             Ineffective_Inline_Warnings         := True;
-            List_Inherited_Aspects              := True;
             Warn_On_Ada_2005_Compatibility      := True;
             Warn_On_Ada_2012_Compatibility      := True;
             Warn_On_Assertion_Failure           := True;