@@ -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;
new file mode 100644
@@ -0,0 +1,11 @@
+-- { 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;