Tokenizer: Fixed unwanted unknownMacro warning for decltype

This commit is contained in:
Daniel Marjamäki 2020-10-27 09:08:13 +01:00
parent 1f6cb7a54b
commit 4eb829933e
4 changed files with 7 additions and 3 deletions

View File

@ -403,7 +403,7 @@ static int multiComparePercent(const Token *tok, const char*& haystack, nonneg i
// Type (%type%)
{
haystack += 5;
if (tok->isName() && tok->varId() == 0 && (tok->str() != "delete" || !tok->isKeyword())) // HACK: this is legacy behaviour, it should return false for all keywords, ecxcept types
if (tok->isName() && tok->varId() == 0 && (tok->str() != "delete" || !tok->isKeyword())) // HACK: this is legacy behaviour, it should return false for all keywords, except types
return 1;
}
break;

View File

@ -9489,7 +9489,7 @@ void Tokenizer::reportUnknownMacros()
unknownMacroError(tok->next());
}
if (Token::Match(tok, "[(,] %name% (") && Token::Match(tok->linkAt(2), ") %name% %name%|,|)")) {
if (tok->linkAt(2)->next()->isKeyword())
if (tok->next()->isKeyword() || tok->linkAt(2)->next()->isKeyword())
continue;
if (cAlternativeTokens.count(tok->linkAt(2)->next()->str()) > 0)
continue;

View File

@ -120,9 +120,9 @@ void TokenList::determineCppC()
if (mIsCpp) {
//mKeywords.insert("bool"); // type
mKeywords.insert("catch");
mKeywords.insert("delete");
mKeywords.insert("class");
mKeywords.insert("const_cast");
mKeywords.insert("decltype");
mKeywords.insert("delete");
mKeywords.insert("dynamic_cast");
mKeywords.insert("explicit");
@ -145,6 +145,7 @@ void TokenList::determineCppC()
mKeywords.insert("try");
mKeywords.insert("typeid");
mKeywords.insert("typename");
mKeywords.insert("typeof");
mKeywords.insert("using");
mKeywords.insert("virtual");
//mKeywords.insert("wchar_t"); // type

View File

@ -8149,6 +8149,9 @@ private:
const char code7[] = "void foo() { dostuff(ZEND_NUM_ARGS() TSRMLS_CC, x, y); }"; // #9476
ASSERT_THROW(tokenizeAndStringify(code7), InternalError);
const char code8[] = "void foo() { a = [](int x, decltype(vec) y){}; }";
ASSERT_NO_THROW(tokenizeAndStringify(code8));
}
void findGarbageCode() { // Test Tokenizer::findGarbageCode()