From 093c03fcd015b163bf5d86dd1e7eeb08737d58fe Mon Sep 17 00:00:00 2001 From: Piotr Trojanek Date: Fri, 24 Oct 2025 23:12:45 +0200 Subject: [PATCH] ada: Ignore declarations of internal types in compile-time evaluation 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 | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/gcc/ada/exp_util.adb b/gcc/ada/exp_util.adb index 15e956469d4..c5c70daac17 100644 --- a/gcc/ada/exp_util.adb +++ b/gcc/ada/exp_util.adb @@ -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 -- 2.47.3