Skip to content

Commit 71cb315

Browse files
committed
fix
1 parent f783ec4 commit 71cb315

1 file changed

Lines changed: 24 additions & 1 deletion

File tree

lib/tokenize.cpp

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5269,7 +5269,29 @@ void Tokenizer::setVarIdPass2()
52695269
std::map<const Token *, std::string> endOfScope;
52705270
std::list<std::string> scope;
52715271
std::list<const Token *> usingnamespaces;
5272+
const Token *enumEnd = nullptr;
52725273
for (Token *tok = list.front(); tok; tok = tok->next()) {
5274+
if (tok->str() == "enum") {
5275+
tok = tok->next();
5276+
if (tok->str() == "class")
5277+
tok = tok->next();
5278+
if (tok->isName())
5279+
tok = tok->next();
5280+
if (tok->str() == ":") {
5281+
tok = tok->next();
5282+
if (tok->str() == "::")
5283+
tok = tok->next();
5284+
while (Token::Match(tok, "%name% ::"))
5285+
tok = tok->tokAt(2);
5286+
tok = tok->next();
5287+
}
5288+
if (tok->str() == "{")
5289+
enumEnd = tok->link();
5290+
}
5291+
if (tok == enumEnd) {
5292+
enumEnd = nullptr;
5293+
continue;
5294+
}
52735295
if (!tok->previous() || Token::Match(tok->previous(), "[;{}]")) {
52745296
if (Token::Match(tok, "using namespace %name% ::|;")) {
52755297
Token *endtok = tok->tokAt(2);
@@ -5299,7 +5321,8 @@ void Tokenizer::setVarIdPass2()
52995321
tok = tok->next()->findClosingBracket()->next();
53005322
else if (usingnamespaces.empty() || tok->varId() || !tok->isName() || tok->isStandardType() || tok->tokType() == Token::eKeyword || tok->tokType() == Token::eBoolean ||
53015323
Token::Match(tok->previous(), ".|namespace|class|struct|&|&&|*|> %name%") || Token::Match(tok->previous(), "%type%| %name% ( %type%|)") || Token::Match(tok, "public:|private:|protected:") ||
5302-
(!tok->next() && Token::Match(tok->previous(), "}|; %name%")))
5324+
(!tok->next() && Token::Match(tok->previous(), "}|; %name%")) ||
5325+
(enumEnd && Token::Match(tok->previous(), "{|, %name% =|,|}")))
53035326
continue;
53045327

53055328
if (tok->strAt(-1) == "::" && tok->tokAt(-2) && tok->tokAt(-2)->isName())

0 commit comments

Comments
 (0)