]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Avoid triggering ghost context errors on prefixed names
authorViljar Indus <indus@adacore.com>
Tue, 7 Oct 2025 09:59:28 +0000 (12:59 +0300)
committerMarc Poulhiès <dkm@gcc.gnu.org>
Mon, 3 Nov 2025 14:15:16 +0000 (15:15 +0100)
Errors for ghost incompatibilities of qualified names should not
be applied to prefixes but rather only the final selector.

gcc/ada/ChangeLog:

* ghost.adb (Is_Ok_Context): consider ghost prefix to always
be a valid ghost context.

gcc/ada/ghost.adb

index e7a55efb4beb858047543ce6bc47d4c7209ab2de..d49d94df246af27efe63c9f75c28f8452cef53b3 100644 (file)
@@ -740,6 +740,14 @@ package body Ghost is
                then
                   return True;
 
+               --  It is always legal to use a ghost prefix. More complex
+               --  scenarios are analyzed for the selector.
+
+               elsif Nkind (Par) = N_Selected_Component
+                 and then Prefix (Par) = Prev
+               then
+                  return True;
+
                elsif Is_OK_Declaration (Par) then
                   return True;