Fixed #6203 (AST: fix problem with '; static_cast<...')

This commit is contained in:
Daniel Marjamäki 2014-10-10 08:18:24 +02:00
parent 8233edcbf2
commit cca003490b
2 changed files with 2 additions and 1 deletions

View File

@ -911,7 +911,7 @@ static Token * createAstAtToken(Token *tok, bool cpp)
if (Token::Match(tok, "%type% <") && Token::Match(tok->linkAt(1), "> !!(")) if (Token::Match(tok, "%type% <") && Token::Match(tok->linkAt(1), "> !!("))
return tok->linkAt(1); return tok->linkAt(1);
if (tok->str() == "return" || !tok->previous() || Token::Match(tok, "%var% %op%|(|[|.|::") || Token::Match(tok->previous(), "[;{}] %cop%|++|--|( !!{")) { if (tok->str() == "return" || !tok->previous() || Token::Match(tok, "%var% %op%|(|[|.|::|<") || Token::Match(tok->previous(), "[;{}] %cop%|++|--|( !!{")) {
Token * const tok1 = tok; Token * const tok1 = tok;
AST_state state(cpp); AST_state state(cpp);
compileExpression(tok, state); compileExpression(tok, state);

View File

@ -8486,6 +8486,7 @@ private:
void asttemplate() const { // uninstantiated templates will have <,>,etc.. void asttemplate() const { // uninstantiated templates will have <,>,etc..
ASSERT_EQUALS("a(3==", testAst("a<int>()==3")); ASSERT_EQUALS("a(3==", testAst("a<int>()==3"));
ASSERT_EQUALS("ab(== f(", testAst("a == b<c>(); f();")); ASSERT_EQUALS("ab(== f(", testAst("a == b<c>(); f();"));
ASSERT_EQUALS("static_casta(i[", testAst("; static_cast<char*>(a)[i];")); // #6203
// This two unit tests were added to avoid a crash. The actual correct AST result for non-executable code has not been determined so far. // This two unit tests were added to avoid a crash. The actual correct AST result for non-executable code has not been determined so far.
ASSERT_EQUALS("Cpublica::b:::", testAst("class C : public ::a::b<bool> { };")); ASSERT_EQUALS("Cpublica::b:::", testAst("class C : public ::a::b<bool> { };"));