Fixed wrong syntax error (#7045)

This commit is contained in:
PKEuS 2015-10-14 16:01:48 +02:00
parent 61d8a73f4c
commit d0cc97a4cf
2 changed files with 3 additions and 2 deletions

View File

@ -10156,13 +10156,13 @@ void Tokenizer::prepareTernaryOpForAST()
unsigned int depth = 0;
Token* tok2 = tok->next();
for (; tok2; tok2 = tok2->next()) {
if (tok2->link() && Token::Match(tok2, "{|[|("))
if (tok2->link() && Token::Match(tok2, "[|(|<"))
tok2 = tok2->link();
else if (tok2->str() == ":") {
if (depth == 0)
break;
depth--;
} else if (tok2->str() == ";" || tok2->link())
} else if (tok2->str() == ";" || (tok2->link() && tok2->str() != "{" && tok2->str() != "}"))
break;
else if (tok2->str() == ",")
paranthesesNeeded = true;

View File

@ -8018,6 +8018,7 @@ private:
ASSERT_EQUALS("fabc,de,:?=", testAst("f = (a ? (b, c) : (d, e));"));
ASSERT_EQUALS("fabc,de,:?=", testAst("f = (a ? b, c : (d, e));"));
ASSERT_EQUALS("ab35,4:?foo(:?return", testAst("return (a ? b ? (3,5) : 4 : foo());"));
ASSERT_EQUALS("check(result_typeinvalid:?return", testAst("return check() ? result_type {0, 0} : invalid;"));
ASSERT_EQUALS("a\"\"=", testAst("a=\"\""));
ASSERT_EQUALS("a\'\'=", testAst("a=\'\'"));