+2019-08-12 Eric Botcazou <ebotcazou@adacore.com>
+
+ * checks.adb (Insert_Valid_Check): Do not retrieve the
+ Do_Range_Check flag from the Original_Node but from the
+ Validated_Object. Remove useless bypass for floating-point
+ types.
+
2019-08-12 Yannick Moy <moy@adacore.com>
* sem_util.adb, sem_util.ads (Traverse_More_Func,
Set_Validated_Object (Var_Id, New_Copy_Tree (Exp));
- -- Reset the Do_Range_Check flag so it doesn't leak elsewhere
-
- Set_Do_Range_Check (Validated_Object (Var_Id), False);
-
Rewrite (Exp, New_Occurrence_Of (Var_Id, Loc));
- -- Copy the Do_Range_Check flag over to the new Exp, so it doesn't
- -- get lost. Floating point types are handled elsewhere.
+ -- Move the Do_Range_Check flag over to the new Exp so it doesn't
+ -- get lost and doesn't leak elsewhere.
- if not Is_Floating_Point_Type (Typ) then
- Set_Do_Range_Check (Exp, Do_Range_Check (Original_Node (Exp)));
+ if Do_Range_Check (Validated_Object (Var_Id)) then
+ Set_Do_Range_Check (Exp);
+ Set_Do_Range_Check (Validated_Object (Var_Id), False);
end if;
PV := New_Occurrence_Of (Var_Id, Loc);
+2019-08-12 Eric Botcazou <ebotcazou@adacore.com>
+
+ * gnat.dg/range_check7.adb: New testcase.
+
2019-08-12 Eric Botcazou <ebotcazou@adacore.com>
* gnat.dg/range_check6.adb: New testcase.
--- /dev/null
+-- { dg-do compile }
+-- { dg-options "-gnatVa" }
+
+procedure Range_Check7 is
+
+ type Short is range -32768 .. 32767;
+
+ type Int is range -2 ** 31 .. 2 ** 31 - 1;
+
+ subtype Nat is Int range 0 .. Int'Last;
+
+ type Ptr is access all Short;
+
+ procedure Proc (P : Ptr) is
+ N : constant Nat := Nat (P.all);
+ begin
+ null;
+ end;
+
+begin
+ null;
+end;