Commit 59ec5d9b by Patrick Bernardi Committed by Pierre-Marie de Rodat

[Ada] Fix compiler abort on invalid discriminant constraint

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
parent 801b4022
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
......
......@@ -9877,6 +9877,12 @@ package body Sem_Ch3 is
("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,
......
-- { 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;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment