]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Fix error on SPARK_Mode on library-level separate body
authorYannick Moy <moy@adacore.com>
Mon, 31 Oct 2022 10:33:12 +0000 (11:33 +0100)
committerMarc Poulhiès <poulhies@adacore.com>
Mon, 14 Nov 2022 13:46:50 +0000 (14:46 +0100)
When applying explicitly SPARK_Mode on a separate library-level spec
and body for which a contract needs to be checked, compilation with
-gnata was failing on a spurious error related to SPARK_Mode
placement. Now fixed.

gcc/ada/

* sem_prag.adb (Analyze_Pragma): Add special case for the special
local subprogram created for contracts.

gcc/ada/sem_prag.adb

index 615c6d2110c6dfe6273638b07f151f9df713bf4a..77fcb1c505f8ca29d92466a090e95033cd39f318 100644 (file)
@@ -23424,10 +23424,14 @@ package body Sem_Prag is
                Spec_Id : constant Entity_Id := Unique_Defining_Entity (Decl);
 
             begin
-               --  Ignore pragma when applied to the special body created for
-               --  inlining, recognized by its internal name _Parent.
+               --  Ignore pragma when applied to the special body created
+               --  for inlining, recognized by its internal name _Parent; or
+               --  when applied to the special body created for contracts,
+               --  recognized by its internal name _Wrapped_Statements.
 
-               if Chars (Body_Id) = Name_uParent then
+               if Chars (Body_Id) in Name_uParent
+                                   | Name_uWrapped_Statements
+               then
                   return;
                end if;