]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Fix bug in resolution of Ghost_Predicate
authorBob Duff <duff@adacore.com>
Mon, 1 Jul 2024 13:23:17 +0000 (09:23 -0400)
committerMarc Poulhiès <dkm@gcc.gnu.org>
Thu, 1 Aug 2024 15:14:36 +0000 (17:14 +0200)
This patch fixes a failure of name resolution when
a range attribute reference appears in a Ghost_Predicate
and the ghost policy is Ignore.

gcc/ada/

* sem_ch13.adb (Add_Predicate): Remove the premature "return;".
Ghost code needs to be processed by later code in this procedure
even when ignored; otherwise the second pass of name resolution
fails much later. However, protect Set_SCO_Pragma_Enabled and
Add_Condition with "if not Is_Ignored_Ghost_Pragma"; these parts
should not happen if the ghost code is Ignored.
* libgnat/interfac__2020.ads (Unsigned_8): Minor reformatting.
* libgnat/interfac.ads (IEEE_Extended_Float): Minor comment
improvement.

gcc/ada/libgnat/interfac.ads
gcc/ada/libgnat/interfac__2020.ads
gcc/ada/sem_ch13.adb

index b57264deb26886fe5962babfa1410b28e72600d2..fe130d016baa5930d21a9e55cdf06d0c527d9055 100644 (file)
@@ -62,7 +62,7 @@ is
    --  such as SPARK or CodePeer. In the normal case Long_Long_Integer is
    --  always 64-bits so we get the desired 64-bit type.
 
-   type Unsigned_8  is mod 2 ** 8;
+   type Unsigned_8 is mod 2 ** 8;
    for Unsigned_8'Size use  8;
 
    type Unsigned_16 is mod 2 ** 16;
index 0b5cc7d43395559740d94c98e73c46cb751edebe..cb20f34b0d7d5f82330e194749839cc38e8d26d1 100644 (file)
@@ -227,6 +227,7 @@ is
    --  Note: it is harmless, and explicitly permitted, to include additional
    --  types in interfaces, so it is not wrong to have IEEE_Extended_Float
    --  defined even if the extended format is not available.
+   --  See RM-B.2(11).
 
    type IEEE_Extended_Float is new Long_Long_Float;
 
index b903381e5deabfe529a6c5829248712452d0a241..171e516bf3d562261a8e56f4b5c16d052e33d03e 100644 (file)
@@ -10218,12 +10218,12 @@ package body Sem_Ch13 is
 
             if Is_Ignored_Ghost_Pragma (Prag) then
                Add_Condition (New_Occurrence_Of (Standard_True, Sloc (Prag)));
-               return;
-            end if;
 
-            --  Mark corresponding SCO as enabled
+            else
+               --  Mark corresponding SCO as enabled
 
-            Set_SCO_Pragma_Enabled (Sloc (Prag));
+               Set_SCO_Pragma_Enabled (Sloc (Prag));
+            end if;
 
             --  Extract the arguments of the pragma
 
@@ -10257,7 +10257,9 @@ package body Sem_Ch13 is
 
                   --  "and"-in the Arg2 condition to evolving expression
 
-                  Add_Condition (Arg2_Copy);
+                  if not Is_Ignored_Ghost_Pragma (Prag) then
+                     Add_Condition (Arg2_Copy);
+                  end if;
                end;
             end if;
          end Add_Predicate;