* [Ada] Fix confusing error expression on an unknown restriction
@ 2022-07-12 12:25 Pierre-Marie de Rodat
0 siblings, 0 replies; only message in thread
From: Pierre-Marie de Rodat @ 2022-07-12 12:25 UTC (permalink / raw)
To: gcc-patches; +Cc: Piotr Trojanek
[-- Attachment #1: Type: text/plain, Size: 544 bytes --]
When pragma Restriction is used with an unknown restriction identifier,
it is better to not process the restriction expression, as it will
likely produce confusing error message.
In particular, an odd message appeared when there was a typo in the
restriction identifier whose expression requires special processing
(e.g. No_Dependence_On instead of No_Dependence).
Tested on x86_64-pc-linux-gnu, committed on trunk
gcc/ada/
* sem_prag.adb (Process_Restrictions_Or_Restriction_Warnings):
Do not process expression of unknown restrictions.
[-- Attachment #2: patch.diff --]
[-- Type: text/x-diff, Size: 844 bytes --]
diff --git a/gcc/ada/sem_prag.adb b/gcc/ada/sem_prag.adb
--- a/gcc/ada/sem_prag.adb
+++ b/gcc/ada/sem_prag.adb
@@ -10792,13 +10792,15 @@ package body Sem_Prag is
else
R_Id := Get_Restriction_Id (Process_Restriction_Synonyms (Arg));
- Analyze_And_Resolve (Expr, Any_Integer);
if R_Id not in All_Parameter_Restrictions then
Error_Pragma_Arg
("invalid restriction parameter identifier", Arg);
+ end if;
+
+ Analyze_And_Resolve (Expr, Any_Integer);
- elsif not Is_OK_Static_Expression (Expr) then
+ if not Is_OK_Static_Expression (Expr) then
Flag_Non_Static_Expr
("value must be static expression!", Expr);
raise Pragma_Exit;
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-07-12 12:25 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-12 12:25 [Ada] Fix confusing error expression on an unknown restriction 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).