Skip to content

Commit 7809a37

Browse files
committed
fix
1 parent c5e9a48 commit 7809a37

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

‎lib/tokenize.cpp‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9487,6 +9487,29 @@ void Tokenizer::findGarbageCode() const
94879487
if (Token::Match(tok, "[;{}] [ %name% %name% ] ;"))
94889488
syntaxError(tok->next());
94899489
}
9490+
9491+
bool statementStart = true;
9492+
for (const Token *tok = tokens(); tok; tok = tok->next()) {
9493+
if (tok->str() == "{") {
9494+
const Token *prev = tok->previous();
9495+
while (Token::Match(prev, "%name%|::") && prev->str() != "namespace")
9496+
prev = prev->previous();
9497+
if (Token::simpleMatch(prev, "namespace") || Token::Match(tok->tokAt(-2), "extern %str% {")) {
9498+
statementStart = true;
9499+
continue;
9500+
}
9501+
tok = tok->link();
9502+
statementStart = false;
9503+
continue;
9504+
}
9505+
if (statementStart && Token::Match(tok, "%name% { !!}") && !tok->isKeyword() &&
9506+
!Token::findsimplematch(tok->next(), ";", tok->linkAt(1))) {
9507+
if (tok->isUpperCaseName())
9508+
unknownMacroError(tok);
9509+
syntaxError(tok);
9510+
}
9511+
statementStart = Token::Match(tok, ";|}");
9512+
}
94909513
}
94919514

94929515

0 commit comments

Comments
 (0)