]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Ignore declarations of internal types in compile-time evaluation
authorPiotr Trojanek <trojanek@adacore.com>
Fri, 24 Oct 2025 21:12:45 +0000 (23:12 +0200)
committerMarc Poulhiès <dkm@gcc.gnu.org>
Thu, 13 Nov 2025 15:36:09 +0000 (16:36 +0100)
One more case where compile-time evaluation can't trace the original location
of an object reference.

gcc/ada/ChangeLog:

* exp_util.adb (Find_In_Enclosing_Context): Give up on declarations of
internal types.

gcc/ada/exp_util.adb

index 15e956469d46c288e42fc63b2f5e93614b0cebb6..c5c70daac17eabe6416a9dd5c4106e7d362da6b5 100644 (file)
@@ -7395,6 +7395,18 @@ package body Exp_Util is
                end if;
                pragma Assert (Present (Current));
 
+            --  For declarations of internal types we can't trace their origin
+            --  like we do for itypes, so give up. They might be coming from
+            --  condition of the current IF statement and will be prepended
+            --  before that statement itself.
+
+            elsif Nkind (Current) = N_Subtype_Declaration
+              and then Is_Internal (Defining_Identifier (Current))
+            then
+               pragma Assert (Is_Rewrite_Insertion (Current));
+               Current := Empty;
+               return;
+
             --  Same for itypes that have no declaration
 
             elsif Nkind (Current) = N_Defining_Identifier