Fix #11029 unknownMacro reported with noexcept (regression) (#4073)

This commit is contained in:
chrchr-github 2022-05-03 13:37:14 +02:00 committed by GitHub
parent e293b66ac6
commit 51b4cf592b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 4 deletions

View File

@ -10196,10 +10196,12 @@ void Tokenizer::reportUnknownMacros() const
unknownMacroError(tok);
}
} else if (Token::Match(tok, "%name% (") && tok->isUpperCaseName() && Token::Match(tok->linkAt(1), ") %name% (") && Token::Match(tok->linkAt(1)->linkAt(2), ") [;{]")) {
if (possible.count(tok->str()) == 0)
possible.insert(tok->str());
else
unknownMacroError(tok);
if (!(tok->linkAt(1)->next() && tok->linkAt(1)->next()->isKeyword())) { // e.g. noexcept(true)
if (possible.count(tok->str()) == 0)
possible.insert(tok->str());
else
unknownMacroError(tok);
}
}
}

View File

@ -6551,6 +6551,9 @@ private:
const char code10[] = "void f(std::exception c) { b(M() M() + N(c.what())); }";
ASSERT_THROW(tokenizeAndStringify(code10), InternalError);
const char code11[] = "struct B { B(B&&) noexcept {} ~B() noexcept {} };";
ASSERT_NO_THROW(tokenizeAndStringify(code11));
}
void findGarbageCode() { // Test Tokenizer::findGarbageCode()