Fix #11045 syntaxError with unknown macros and using namespace (#4086)

This commit is contained in:
chrchr-github 2022-05-05 19:47:56 +02:00 committed by GitHub
parent f3ae729f89
commit 612d7be85a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 1 deletions

View File

@ -4204,7 +4204,8 @@ void Tokenizer::setVarIdPass2()
else if (Token::Match(tok->previous(), "!!:: %name% <") && Token::Match(tok->next()->findClosingBracket(),"> :: ~| %name%"))
tok = tok->next()->findClosingBracket()->next();
else if (usingnamespaces.empty() || tok->varId() || !tok->isName() || tok->isStandardType() || tok->tokType() == Token::eKeyword || tok->tokType() == Token::eBoolean ||
Token::Match(tok->previous(), ".|namespace|class|struct|&|&&|*|> %name%") || Token::Match(tok->previous(), "%type%| %name% ( %type%|)") || Token::Match(tok, "public:|private:|protected:"))
Token::Match(tok->previous(), ".|namespace|class|struct|&|&&|*|> %name%") || Token::Match(tok->previous(), "%type%| %name% ( %type%|)") || Token::Match(tok, "public:|private:|protected:") ||
(!tok->next() && Token::Match(tok->previous(), "}|; %name%")))
continue;
while (Token::Match(tok, ":: ~| %name%")) {

View File

@ -4528,6 +4528,8 @@ private:
// Handle garbage enum code "well"
ASSERT_EQUALS("enum E : int ; void foo ( ) { std :: string s ; }",
tokenizeAndStringify("using namespace std; enum E : int ; void foo ( ) { string s ; }"));
ASSERT_NO_THROW(tokenizeAndStringify("NS_BEGIN(IMAGEIO_2D_DICOM) using namespace std; NS_END")); // #11045
}
void microsoftMemory() {