* Fix #11332 Function::addArguments found argument 'b' with varid 0 with lambda parameter * Fix varid0 warning
This commit is contained in:
parent
fc39a4d1bb
commit
64f3f85804
|
@ -4563,7 +4563,7 @@ const Token *Scope::checkVariable(const Token *tok, AccessControl varaccess, con
|
|||
}
|
||||
|
||||
// skip const|volatile|static|mutable|extern
|
||||
while (tok->isKeyword() && Token::Match(tok, "const|constexpr|volatile|static|mutable|extern")) {
|
||||
while (tok && tok->isKeyword() && Token::Match(tok, "const|constexpr|volatile|static|mutable|extern")) {
|
||||
tok = tok->next();
|
||||
}
|
||||
|
||||
|
@ -4580,7 +4580,7 @@ const Token *Scope::checkVariable(const Token *tok, AccessControl varaccess, con
|
|||
return typeend->linkAt(1);
|
||||
}
|
||||
|
||||
if (tok->isKeyword() && Token::Match(tok, "class|struct|union|enum")) {
|
||||
while (tok && tok->isKeyword() && Token::Match(tok, "class|struct|union|enum")) {
|
||||
tok = tok->next();
|
||||
}
|
||||
|
||||
|
|
|
@ -3973,7 +3973,7 @@ void Tokenizer::setVarIdPass1()
|
|||
Token::Match(tok, "[;{}]") ||
|
||||
(tok->str() == "(" && isFunctionHead(tok,"{")) ||
|
||||
(tok->str() == "(" && !scopeStack.top().isExecutable && isFunctionHead(tok,";:")) ||
|
||||
(tok->str() == "," && (!scopeStack.top().isExecutable || inlineFunction)) ||
|
||||
(tok->str() == "," && (!scopeStack.top().isExecutable || inlineFunction || !tok->previous()->varId())) ||
|
||||
(tok->isName() && endsWith(tok->str(), ':')))) {
|
||||
|
||||
// No variable declarations in sizeof
|
||||
|
|
|
@ -379,6 +379,7 @@ private:
|
|||
TEST_CASE(enum8);
|
||||
TEST_CASE(enum9);
|
||||
TEST_CASE(enum10); // #11001
|
||||
TEST_CASE(enum11);
|
||||
|
||||
TEST_CASE(sizeOfType);
|
||||
|
||||
|
@ -5367,6 +5368,11 @@ private:
|
|||
ASSERT_EQUALS(Y->value, 1);
|
||||
}
|
||||
|
||||
void enum11() {
|
||||
check("enum class E;\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void sizeOfType() {
|
||||
// #7615 - crash in Symboldatabase::sizeOfType()
|
||||
GET_SYMBOL_DB("enum e;\n"
|
||||
|
|
|
@ -2761,6 +2761,16 @@ private:
|
|||
"5: } ;\n";
|
||||
ASSERT_EQUALS(exp, tokenize(code));
|
||||
}
|
||||
// # 11332
|
||||
{
|
||||
const char code[] = "auto a() {\n"
|
||||
" return [](int, int b) {};\n"
|
||||
"}\n";
|
||||
const char exp[] = "1: auto a ( ) {\n"
|
||||
"2: return [ ] ( int , int b@1 ) { } ;\n"
|
||||
"3: }\n";
|
||||
ASSERT_EQUALS(exp, tokenize(code));
|
||||
}
|
||||
}
|
||||
|
||||
void varid_lambda_mutable() {
|
||||
|
|
Loading…
Reference in New Issue