aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada
diff options
context:
space:
mode:
authorYannick Moy <moy@adacore.com>2019-07-22 13:57:42 +0000
committerPierre-Marie de Rodat <pmderodat@gcc.gnu.org>2019-07-22 13:57:42 +0000
commit5dcbefb1c407fcb949597c4257726bfbc8760cfb (patch)
tree6928b39af2499baa60b204bbfde87cf73296573e /gcc/ada
parent116992570783944a12e64e63db9f5a2445e10016 (diff)
downloadgcc-5dcbefb1c407fcb949597c4257726bfbc8760cfb.zip
gcc-5dcbefb1c407fcb949597c4257726bfbc8760cfb.tar.gz
gcc-5dcbefb1c407fcb949597c4257726bfbc8760cfb.tar.bz2
[Ada] Issue warning or error message on ignored typing constraint
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
Diffstat (limited to 'gcc/ada')
-rw-r--r--gcc/ada/ChangeLog5
-rw-r--r--gcc/ada/sem_ch3.adb4
2 files changed, 9 insertions, 0 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog
index 06e6421..f47d247 100644
--- a/gcc/ada/ChangeLog
+++ b/gcc/ada/ChangeLog
@@ -1,3 +1,8 @@
+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
diff --git a/gcc/ada/sem_ch3.adb b/gcc/ada/sem_ch3.adb
index d8cd348..645a024 100644
--- a/gcc/ada/sem_ch3.adb
+++ b/gcc/ada/sem_ch3.adb
@@ -12970,6 +12970,10 @@ package body Sem_Ch3 is
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));