From d994e9c867c78e17f7b4a50d410896dd1d13ac4d Mon Sep 17 00:00:00 2001 From: Devajith Valaparambil Sreeramaswamy Date: Sun, 28 Apr 2024 12:54:22 +0200 Subject: [PATCH] [TCling] Do not add decls for control statements if already annotated --- core/metacling/src/TClingCallbacks.cxx | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/core/metacling/src/TClingCallbacks.cxx b/core/metacling/src/TClingCallbacks.cxx index edbd33107192aa..5a6fe519f27b3c 100644 --- a/core/metacling/src/TClingCallbacks.cxx +++ b/core/metacling/src/TClingCallbacks.cxx @@ -845,6 +845,12 @@ bool TClingCallbacks::tryResolveAtRuntimeInternal(LookupResult &R, Scope *S) { return false; } + // Prevent redundant declarations for control statements (e.g., for, if, while) + // that have already been annotated. + if (auto annot = Wrapper->getAttr()) + if (annot->getAnnotation().equals("__ResolveAtRuntime") && S->isControlScope()) + return false; + VarDecl* Result = VarDecl::Create(C, TU, Loc, Loc, II, C.DependentTy, /*TypeSourceInfo*/nullptr, SC_None);