public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [Ada] Complain about missing -gnat2020 switch on iterator_filter
@ 2020-12-15 11:42 Pierre-Marie de Rodat
  0 siblings, 0 replies; only message in thread
From: Pierre-Marie de Rodat @ 2020-12-15 11:42 UTC (permalink / raw)
  To: gcc-patches; +Cc: Piotr Trojanek

[-- Attachment #1: Type: text/plain, Size: 497 bytes --]

Reuse Error_Msg_Ada_2020_Feature to complain about a missing -gnat2020
switch when compiling iterator_filter that would be legal in Ada 2020,
but the compiler is expecting an earlier version of the language.

A small enhancement; opportunity spotted while adding support for
iterator filters in GNATprove.

Tested on x86_64-pc-linux-gnu, committed on trunk

gcc/ada/

	* par-ch5.adb (P_Loop_Parameter_Specification): Complain about
	missing -gnat2020 switch.
	(P_Iterator_Specification): Likewise.

[-- Attachment #2: patch.diff --]
[-- Type: text/x-diff, Size: 924 bytes --]

diff --git a/gcc/ada/par-ch5.adb b/gcc/ada/par-ch5.adb
--- a/gcc/ada/par-ch5.adb
+++ b/gcc/ada/par-ch5.adb
@@ -1712,9 +1712,9 @@ package body Ch5 is
       Set_Discrete_Subtype_Definition
         (Loop_Param_Specification_Node, P_Discrete_Subtype_Definition);
 
-      if Ada_Version >= Ada_2020
-         and then Token = Tok_When
-      then
+      if Token = Tok_When then
+         Error_Msg_Ada_2020_Feature ("iterator filter", Token_Ptr);
+
          Scan; -- past WHEN
          Set_Iterator_Filter
            (Loop_Param_Specification_Node, P_Condition);
@@ -1773,9 +1773,9 @@ package body Ch5 is
 
       Set_Name (Node1, P_Name);
 
-      if Ada_Version >= Ada_2020
-         and then Token = Tok_When
-      then
+      if Token = Tok_When then
+         Error_Msg_Ada_2020_Feature ("iterator filter", Token_Ptr);
+
          Scan; -- past WHEN
          Set_Iterator_Filter
            (Node1, P_Condition);



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-12-15 11:42 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-15 11:42 [Ada] Complain about missing -gnat2020 switch on iterator_filter Pierre-Marie de Rodat

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).