]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Accept Assert pragmas in expression functions
authorSteve Baird <baird@adacore.com>
Fri, 3 Feb 2023 01:33:53 +0000 (17:33 -0800)
committerMarc Poulhiès <poulhies@adacore.com>
Mon, 22 May 2023 08:44:10 +0000 (10:44 +0200)
gcc/ada/

* sem_ch4.adb (Analyze_Expression_With_Actions.Check_Action_Ok):
Accept an executable pragma occuring in a declare expression as
per AI22-0045. This means Assert and Inspection_Point pragmas as
well as any implementation-defined pragmas that the implementation
chooses to categorize as executable. Currently Assume and Debug
are the only such pragmas.

gcc/ada/sem_ch4.adb

index e9c5b9f8a33d112beb72ccc69fc287edea0a18e5..5b013dfb63d7f3e8654c6548cb837539bcabfaca 100644 (file)
@@ -2411,10 +2411,27 @@ package body Sem_Ch4 is
                   return; -- ???For now; the RM rule is a bit more complicated
                end if;
 
+            when N_Pragma =>
+               declare
+                  --  See AI22-0045 pragma categorization.
+                  subtype Executable_Pragma_Id is Pragma_Id
+                    with Predicate => Executable_Pragma_Id in
+                        --  language-defined executable pragmas
+                      Pragma_Assert | Pragma_Inspection_Point
+
+                        --  GNAT-defined executable pragmas
+                        | Pragma_Assume | Pragma_Debug;
+               begin
+                  if Get_Pragma_Id (A) in Executable_Pragma_Id then
+                     return;
+                  end if;
+               end;
+
             when others =>
-               null; -- Nothing else allowed, not even pragmas
+               null; -- Nothing else allowed
          end case;
 
+         --  We could mention pragmas in the message text; let's not.
          Error_Msg_N ("object renaming or constant declaration expected", A);
       end Check_Action_OK;