+2019-07-09 Javier Miranda <miranda@adacore.com>
+
+ * exp_util.adb (Remove_Side_Effects): Preserve the
+ Do_Range_Check flag.
+
2019-07-09 Yannick Moy <moy@adacore.com>
* sinfo.ads: Refine comment for Do_Range_Check.
Set_Assignment_OK (Res, Assignment_OK (Exp));
+ -- Preserve the Do_Range_Check flag in all copies.
+
+ Set_Do_Range_Check (Res, Do_Range_Check (Exp));
+
-- Finally rewrite the original expression and we are done
Rewrite (Exp, Res);
+2019-07-09 Javier Miranda <miranda@adacore.com>
+
+ * gnat.dg/range_check3.adb, gnat.dg/range_check3_pkg.adb,
+ gnat.dg/range_check3_pkg.ads: New testcase.
+
2019-07-09 Ed Schonberg <schonberg@adacore.com>
* gnat.dg/generic_inst5.adb, gnat.dg/generic_inst6.adb,
--- /dev/null
+-- { dg-do run }
+-- { dg-options "-gnatVa" }
+
+with Range_Check3_Pkg; use Range_Check3_Pkg;
+procedure Range_Check3 is
+ Ptr : Array_Access;
+begin
+ Ptr := Allocate;
+ raise Program_Error;
+exception
+ when Constraint_Error => null;
+end Range_Check3;
+
--- /dev/null
+package body Range_Check3_Pkg is
+ function One return Positive is
+ begin
+ return 1;
+ end One;
+
+ function Zero return Natural is
+ begin
+ return 0;
+ end Zero;
+
+ function Allocate return Array_Access is
+ begin
+ return
+ new Array_Type
+ (Positive (One) .. Positive (Zero)); -- Failed range check
+ end Allocate;
+end Range_Check3_Pkg;
--- /dev/null
+package Range_Check3_Pkg is
+ type Array_Type is array (Positive range <>) of Integer;
+ type Array_Access is access Array_Type;
+
+ function One return Positive;
+ function Zero return Natural;
+
+ function Allocate return Array_Access;
+end Range_Check3_Pkg;