]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[Ada] Fix confusing error expression on an unknown restriction
authorPiotr Trojanek <trojanek@adacore.com>
Thu, 23 Jun 2022 11:09:51 +0000 (13:09 +0200)
committerPierre-Marie de Rodat <derodat@adacore.com>
Tue, 12 Jul 2022 12:24:14 +0000 (12:24 +0000)
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).

gcc/ada/

* sem_prag.adb (Process_Restrictions_Or_Restriction_Warnings):
Do not process expression of unknown restrictions.

gcc/ada/sem_prag.adb

index a24d19eacbb76dc7d970964673c1d7cee09f939f..35910400cf9afeaacafee30e85ed40e9c4680b7d 100644 (file)
@@ -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;