aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada
diff options
context:
space:
mode:
authorPatrick Bernardi <bernardi@adacore.com>2018-05-22 13:26:05 +0000
committerPierre-Marie de Rodat <pmderodat@gcc.gnu.org>2018-05-22 13:26:05 +0000
commit59ec5d9be29535f41ecd7840fcb11708edd584f3 (patch)
tree35b97b87ce56b9febd379836338036e6b1954e5f /gcc/ada
parent801b4022e11b50c4124b489ccc621332b2d92946 (diff)
downloadgcc-59ec5d9be29535f41ecd7840fcb11708edd584f3.zip
gcc-59ec5d9be29535f41ecd7840fcb11708edd584f3.tar.gz
gcc-59ec5d9be29535f41ecd7840fcb11708edd584f3.tar.bz2
[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
Diffstat (limited to 'gcc/ada')
-rw-r--r--gcc/ada/ChangeLog5
-rw-r--r--gcc/ada/sem_ch3.adb6
2 files changed, 11 insertions, 0 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog
index aa3a1c0..5a59057 100644
--- a/gcc/ada/ChangeLog
+++ b/gcc/ada/ChangeLog
@@ -1,3 +1,8 @@
+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
diff --git a/gcc/ada/sem_ch3.adb b/gcc/ada/sem_ch3.adb
index 994562d..83938c2 100644
--- a/gcc/ada/sem_ch3.adb
+++ b/gcc/ada/sem_ch3.adb
@@ -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;