Merge pull request #2739 from dan-42/fix_ticket_9839_ast_error
Fix ticket 9839: AST broken; range for loop that uses decltype
This commit is contained in:
commit
6446790d48
|
@ -485,6 +485,9 @@ static Token * skipDecl(Token *tok)
|
||||||
} else if (Token::Match(vartok, "%var% [:=(]")) {
|
} else if (Token::Match(vartok, "%var% [:=(]")) {
|
||||||
return vartok;
|
return vartok;
|
||||||
}
|
}
|
||||||
|
else if (Token::simpleMatch(vartok, "decltype (")) {
|
||||||
|
return vartok->linkAt(1)->next();
|
||||||
|
}
|
||||||
vartok = vartok->next();
|
vartok = vartok->next();
|
||||||
}
|
}
|
||||||
return tok;
|
return tok;
|
||||||
|
|
|
@ -6291,6 +6291,10 @@ private:
|
||||||
" for (const auto & e : array)\n"
|
" for (const auto & e : array)\n"
|
||||||
" foo(e);\n"
|
" foo(e);\n"
|
||||||
" }\n"
|
" }\n"
|
||||||
|
" void f3() {\n"
|
||||||
|
" for (decltype(auto) e : array)\n"
|
||||||
|
" foo(e);\n"
|
||||||
|
" }\n"
|
||||||
"};");
|
"};");
|
||||||
ASSERT_EQUALS("[test.cpp:8]: (style, inconclusive) Technically the member function 'Fred::f2' can be const.\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:8]: (style, inconclusive) Technically the member function 'Fred::f2' can be const.\n", errout.str());
|
||||||
}
|
}
|
||||||
|
|
|
@ -7538,6 +7538,7 @@ private:
|
||||||
ASSERT_EQUALS("forx0=y(8<z;;(", testAst("for (x=0;(int)y<8;z);"));
|
ASSERT_EQUALS("forx0=y(8<z;;(", testAst("for (x=0;(int)y<8;z);"));
|
||||||
ASSERT_EQUALS("forab,c:(", testAst("for (auto [a,b]: c);"));
|
ASSERT_EQUALS("forab,c:(", testAst("for (auto [a,b]: c);"));
|
||||||
ASSERT_EQUALS("fora*++;;(", testAst("for (++(*a);;);"));
|
ASSERT_EQUALS("fora*++;;(", testAst("for (++(*a);;);"));
|
||||||
|
ASSERT_EQUALS("foryz:(", testAst("for (decltype(x) *y : z);"));
|
||||||
|
|
||||||
// problems with multiple expressions
|
// problems with multiple expressions
|
||||||
ASSERT_EQUALS("ax( whilex(", testAst("a(x) while (x)"));
|
ASSERT_EQUALS("ax( whilex(", testAst("a(x) while (x)"));
|
||||||
|
|
Loading…
Reference in New Issue