[multiple changes]
authorArnaud Charlet <charlet@gcc.gnu.org>
Mon, 4 Aug 2014 08:07:57 +0000 (10:07 +0200)
committerArnaud Charlet <charlet@gcc.gnu.org>
Mon, 4 Aug 2014 08:07:57 +0000 (10:07 +0200)
2014-08-04  Ed Schonberg  <schonberg@adacore.com>

* sem_util.adb (Is_Potentially_Unevaluated): If the original
node of a parent node in the tree is a short-circuit operation,
the node is potentially unevaluated.

2014-08-04  Robert Dewar  <dewar@adacore.com>

* sem_res.adb (Resolve_Type_Conversion): Set Do_Range_Check on
conversion from a real type to an integer type.

From-SVN: r213538

gcc/ada/ChangeLog
gcc/ada/sem_res.adb
gcc/ada/sem_util.adb

index 09575ebfab3cdf04fecb5bd3dcdc156b531d9f49..b797f135baf883c315716ac9487bd891a72ddfb0 100644 (file)
@@ -1,3 +1,14 @@
+2014-08-04  Ed Schonberg  <schonberg@adacore.com>
+
+       * sem_util.adb (Is_Potentially_Unevaluated): If the original
+       node of a parent node in the tree is a short-circuit operation,
+       the node is potentially unevaluated.
+
+2014-08-04  Robert Dewar  <dewar@adacore.com>
+
+       * sem_res.adb (Resolve_Type_Conversion): Set Do_Range_Check on
+       conversion from a real type to an integer type.
+
 2014-08-04  Yannick Moy  <moy@adacore.com>
 
        * sem_aggr.adb, sem_ch3.adb, sem_ch5.adb, sem_ch7.adb, sem_ch9.adb,
index b7fa5f523bd121410d6abdc028032e799e25aa74..87024ee92f56b952de7d4af42a8228148f2480e4 100644 (file)
@@ -10322,11 +10322,11 @@ package body Sem_Res is
          --  odd subtype coming from the bounds).
 
          if (Is_Entity_Name (Orig_N)
-               and then
-                 (Etype (Entity (Orig_N)) = Orig_T
-                   or else
-                     (Ekind (Entity (Orig_N)) = E_Loop_Parameter
-                       and then Covers (Orig_T, Etype (Entity (Orig_N))))))
+              and then
+                (Etype (Entity (Orig_N)) = Orig_T
+                  or else
+                    (Ekind (Entity (Orig_N)) = E_Loop_Parameter
+                      and then Covers (Orig_T, Etype (Entity (Orig_N))))))
 
            --  If not an entity, then type of expression must match
 
@@ -10504,6 +10504,17 @@ package body Sem_Res is
             Apply_Predicate_Check (N, Target_Typ);
          end if;
       end if;
+
+      --  If at this stage we have a real to integer conversion, make sure
+      --  that the Do_Range_Check flag is set, because such conversions in
+      --  general need a range check.
+
+      if Nkind (N) = N_Type_Conversion
+        and then Is_Integer_Type (Target_Typ)
+        and then Is_Real_Type (Operand_Typ)
+      then
+         Set_Do_Range_Check (Operand);
+      end if;
    end Resolve_Type_Conversion;
 
    ----------------------
index 4c8bddd515bda7e4983f88655dd24cc2a40ee7f2..5c1a5a8011ee6e2c2f6015ebb30e43a166a52fc1 100644 (file)
@@ -11146,6 +11146,17 @@ package body Sem_Util is
    begin
       Expr := N;
       Par  := Parent (N);
+
+      --  A postcondition whose expression is a short-circuit is broken down
+      --  into individual aspects for better exception reporting. The original
+      --  short-circuit expression is rewritten as the second operand, and an
+      --  occurrence of 'Old in that operand is potentially unevaluated.
+      --  See Sem_ch13.adb for details of this transformation.
+
+      if Nkind (Original_Node (Par)) =  N_And_Then then
+         return True;
+      end if;
+
       while not Nkind_In (Par, N_If_Expression,
                                N_Case_Expression,
                                N_And_Then,