* Update tokenlist.cpp * Update testincompletestatement.cpp * Fix #11370 FP constStatement with lambda * Format
This commit is contained in:
parent
d717e62ec3
commit
ccf2176664
|
@ -493,6 +493,17 @@ static Token * createAstAtToken(Token *tok, bool cpp);
|
|||
|
||||
static Token* skipDecl(Token* tok, std::vector<Token*>* inner = nullptr)
|
||||
{
|
||||
auto isDecltypeFuncParam = [](const Token* tok) -> bool {
|
||||
if (!Token::simpleMatch(tok, ")"))
|
||||
return false;
|
||||
tok = tok->next();
|
||||
while (Token::Match(tok, "*|&|&&|const"))
|
||||
tok = tok->next();
|
||||
if (Token::simpleMatch(tok, "("))
|
||||
tok = tok->link()->next();
|
||||
return Token::Match(tok, "%name%| ,|)");
|
||||
};
|
||||
|
||||
if (!Token::Match(tok->previous(), "( %name%"))
|
||||
return tok;
|
||||
Token *vartok = tok;
|
||||
|
@ -504,7 +515,7 @@ static Token* skipDecl(Token* tok, std::vector<Token*>* inner = nullptr)
|
|||
return tok;
|
||||
} else if (Token::Match(vartok, "%var% [:=(]")) {
|
||||
return vartok;
|
||||
} else if (Token::Match(vartok, "decltype|typeof (") && !Token::Match(tok->linkAt(1), ") [,)]")) {
|
||||
} else if (Token::Match(vartok, "decltype|typeof (") && !isDecltypeFuncParam(tok->linkAt(1))) {
|
||||
if (inner)
|
||||
inner->push_back(vartok->tokAt(2));
|
||||
return vartok->linkAt(1)->next();
|
||||
|
|
|
@ -709,6 +709,12 @@ private:
|
|||
" (*s).i;\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("[test.cpp:3]: (warning) Redundant code: Found unused member access.\n", errout.str());
|
||||
|
||||
check("int a[2];\n" // #11370
|
||||
"void f() {\n"
|
||||
" auto g = [](decltype(a[0]) i) {};\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void vardecl() {
|
||||
|
|
|
@ -6243,6 +6243,10 @@ private:
|
|||
ASSERT_EQUALS("decltypexy+(yx+{", testAst("decltype(x+y){y+x};"));
|
||||
ASSERT_EQUALS("adecltypeac::(,decltypead::(,",
|
||||
testAst("template <typename a> void b(a &, decltype(a::c), decltype(a::d));"));
|
||||
ASSERT_EQUALS("g{([= decltypea0[(",
|
||||
testAst("auto g = [](decltype(a[0]) i) {};"));
|
||||
ASSERT_EQUALS("g{([= decltypea0[(i&",
|
||||
testAst("auto g = [](decltype(a[0])& i) {};"));
|
||||
|
||||
ASSERT_NO_THROW(tokenizeAndStringify("struct A;\n" // #10839
|
||||
"struct B { A* hash; };\n"
|
||||
|
|
Loading…
Reference in New Issue