Skip to content

Commit

Permalink
[TCling] Fix suppression of enum forward declarations
Browse files Browse the repository at this point in the history
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 cms-sw/cmssw#42234), so we have
to look for the last closing parentheses.

(cherry picked from commit 9d2f761)
  • Loading branch information
hahnjo committed Jul 26, 2023
1 parent 556ddda commit 48415a9
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions core/metacling/src/TCling.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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]))
Expand Down

0 comments on commit 48415a9

Please sign in to comment.