+2019-07-22 Ed Schonberg <schonberg@adacore.com>
+
+ * exp_ch4.adb (Expand_N_In): Do not suggest the use of attribute
+ 'Valid as a replacement for a range check on a discrete type
+ when the bounds of the range are given by type conversions,
+ because in such a case there are distinct types involved and the
+ subbested attribute replacement would be misplaced.
+
2019-07-22 Yannick Moy <moy@adacore.com>
* sem_spark.adb (Get_Root_Object, Is_Path_Expression,
-- Similarly, do not rewrite membership as a validity check if
-- within the predicate function for the type.
+ -- Finally, if the original bounds are type conversions, even
+ -- if they have been folded into constants, there are different
+ -- types involved and 'Valid is not appropriate.
+
then
if In_Instance
or else (Ekind (Current_Scope) = E_Function
then
null;
+ elsif Nkind (Lo_Orig) = N_Type_Conversion
+ or else Nkind (Hi_Orig) = N_Type_Conversion
+ then
+ null;
+
else
Substitute_Valid_Check;
goto Leave;
+2019-07-22 Ed Schonberg <schonberg@adacore.com>
+
+ * gnat.dg/warn26.adb: New testcase.
+
2019-07-22 Javier Miranda <miranda@adacore.com>
* gnat.dg/class_wide5.adb: New testcase.
--- /dev/null
+-- { dg-do compile }
+
+procedure Warn26 is
+
+ Monitor_Period_Min : constant := 5;
+ Monitor_Period_Max : constant := 30;
+
+ type Monitor_Period is range Monitor_Period_Min .. Monitor_Period_Max;
+
+ subtype Period_T is Positive range 5 .. 30;
+
+ function Id (X : Period_T) return Period_T is (X);
+ Input_Period : Period_T := Id (20);
+begin
+ if Input_Period in
+ Integer (Monitor_Period'First) .. Integer ( Monitor_Period'Last)
+ then
+ null;
+ end if;
+end Warn26;