GNAT ignores the discriminant constraint on a component when it applies
to the type of the record being analyzed. Now issue a warning on Ada
code when ignoring this constraint, or an error on SPARK code.
2019-07-22 Yannick Moy <moy@adacore.com>
gcc/ada/
* sem_ch3.adb (Constrain_Access): Issue a message about ignored
constraint.
gcc/testsuite/
* gnat.dg/warn24.adb: New testcase.
From-SVN: r273684
+2019-07-22 Yannick Moy <moy@adacore.com>
+
+ * sem_ch3.adb (Constrain_Access): Issue a message about ignored
+ constraint.
+
2019-07-22 Eric Botcazou <ebotcazou@adacore.com>
* sem_ch8.adb (End_Use_Type): Reset the In_Use flag on the
if Desig_Type = Current_Scope
and then No (Def_Id)
then
+ Error_Msg_Warn := SPARK_Mode /= On;
+ Error_Msg_N ("<<constraint is ignored on component that is "
+ & "access to current record", S);
+
Set_Ekind (Desig_Subtype, E_Record_Subtype);
Def_Id := Entity (Subtype_Mark (S));
+2019-07-22 Yannick Moy <moy@adacore.com>
+
+ * gnat.dg/warn24.adb: New testcase.
+
2019-07-22 Eric Botcazou <ebotcazou@adacore.com>
* gnat.dg/inline17.adb, gnat.dg/inline17_pkg1.adb,
--- /dev/null
+-- { dg-do compile }
+
+procedure Warn24 is
+ type List_D (D : Boolean);
+
+ type List_Acc is access List_D;
+
+ type List_D (D : Boolean) is record
+ Next : List_Acc (D); -- { dg-warning "constraint is ignored on component that is access to current record" }
+ end record;
+
+ X : List_D (True);
+begin
+ X.Next := new List_D (False);
+end Warn24;