From 72de114c23027f1d1f0df4c78e69c4302e39e058 Mon Sep 17 00:00:00 2001 From: Gary Dismukes Date: Tue, 5 Apr 2022 20:20:10 -0400 Subject: [Ada] Improve error messages for occurrence of GNAT extensions without -gnatX The error message issued for use of GNAT extension features without specifying -gnatX (or pragma Extensions_Allowed) was confusing in the presence of a pragma specifying a language version (such as "pragma Ada_2022;"), because the pragma supersedes the switch. The message is improved by testing for use of such a pragma, plus use of pragma Extensions_Allowed is now suggested, and several cases are changed to call the common error procedure for flagging uses of extension features. gcc/ada/ * errout.ads (Error_Msg_GNAT_Extension): Add formal Loc and revise comment. * errout.adb (Error_Msg_GNAT_Extension): Condition message on the flag Ada_Version_Pragma, and add suggestion to use of pragma Extensions_Allowed in messages. * par-ch3.adb, par-ch5.adb, par-ch6.adb, par-ch11.adb, par-ch12.adb: Add actual Token_Ptr on calls to Error_Msg_GNAT_Extension. * par-ch4.adb: Change Error_Msg to Error_Msg_GNAT_Extension for error calls related to use of extension features. * sem_ch13.adb: Likewise. --- gcc/ada/par-ch4.adb | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'gcc/ada/par-ch4.adb') diff --git a/gcc/ada/par-ch4.adb b/gcc/ada/par-ch4.adb index bfefd14..e0f3ca9 100644 --- a/gcc/ada/par-ch4.adb +++ b/gcc/ada/par-ch4.adb @@ -1783,9 +1783,8 @@ package body Ch4 is Box_With_Identifier_Present := True; Scan; -- past ">" else - Error_Msg - ("Identifier within box only supported under -gnatX", - Token_Ptr); + Error_Msg_GNAT_Extension + ("identifier within box", Token_Ptr); Box_Present := True; -- Avoid cascading errors by ignoring the identifier end if; @@ -1816,10 +1815,8 @@ package body Ch4 is Id := P_Defining_Identifier; if not Extensions_Allowed then - Error_Msg - ("IS following component association" - & " only supported under -gnatX", - Token_Ptr); + Error_Msg_GNAT_Extension + ("IS following component association", Token_Ptr); elsif Box_With_Identifier_Present then Error_Msg ("Both identifier-in-box and trailing identifier" -- cgit v1.1