This patch fixes a compiler abort on a discriminant constraint when the
constraint is a subtype indication.
2018-05-22 Patrick Bernardi <bernardi@adacore.com>
gcc/ada/
* sem_ch3.adb (Build_Discriminant_Constraints): Raise an error if the
user tries to use a subtype indication as a discriminant constraint.
gcc/testsuite/
* gnat.dg/discr50.adb: New testcase.
From-SVN: r260525
+2018-05-22 Patrick Bernardi <bernardi@adacore.com>
+
+ * sem_ch3.adb (Build_Discriminant_Constraints): Raise an error if the
+ user tries to use a subtype indication as a discriminant constraint.
+
2018-05-22 Ed Schonberg <schonberg@adacore.com>
* exp_ch4.ads, exp_ch4.adb, exp_util.adb, expander.adb: Remove mention
("a range is not a valid discriminant constraint", Constr);
Discr_Expr (D) := Error;
+ elsif Nkind (Constr) = N_Subtype_Indication then
+ Error_Msg_N
+ ("a subtype indication is not a valid discriminant constraint",
+ Constr);
+ Discr_Expr (D) := Error;
+
else
Process_Discriminant_Expression (Constr, Discr);
Discr_Expr (D) := Constr;
+2018-05-22 Patrick Bernardi <bernardi@adacore.com>
+
+ * gnat.dg/discr50.adb: New testcase.
+
2018-05-22 Ed Schonberg <schonberg@adacore.com>
* gnat.dg/discr49.adb, gnat.dg/discr49_rec1.adb,
--- /dev/null
+-- { dg-do compile }
+
+procedure Discr50 is
+ type My_Record (D : Integer) is record
+ A : Integer;
+ end record;
+
+ B : My_Record (Positive range 1 .. 10); -- { dg-error "a subtype indication is not a valid discriminant constraint" }
+begin
+ null;
+end Discr50;