From 48415a93b59fd76e45263a0813bfb5fb39a3539d Mon Sep 17 00:00:00 2001 From: Jonas Hahnfeld Date: Tue, 25 Jul 2023 15:59:32 +0200 Subject: [PATCH] [TCling] Fix suppression of enum forward declarations There can be multiple attributes in the forward declaration, see the added test in roottest/cling/dict/enum (reduced from a case reported by CMS in https://github.com/cms-sw/cmssw/issues/42234), so we have to look for the last closing parentheses. (cherry picked from commit 9d2f7612a6e88d3a7148b19e131402349bac509b) --- core/metacling/src/TCling.cxx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/core/metacling/src/TCling.cxx b/core/metacling/src/TCling.cxx index 9aaae6f2f385f..a571fe5f5f1db 100644 --- a/core/metacling/src/TCling.cxx +++ b/core/metacling/src/TCling.cxx @@ -2194,8 +2194,10 @@ void TCling::RegisterModule(const char* modulename, } } if (scopes.empty() || DC) { - // We know the scope; let's look for the enum. - size_t posEnumName = fwdDeclsLine.find("\"))) ", 32); + // We know the scope; let's look for the enum. For that, look + // for the *last* closing parentheses of an attribute because + // there can be multiple. + size_t posEnumName = fwdDeclsLine.rfind("\"))) "); R__ASSERT(posEnumName != std::string::npos && "Inconsistent enum fwd decl!"); posEnumName += 5; // skip "\"))) " while (isspace(fwdDeclsLine[posEnumName]))