Fixed wrong syntax error (#7045)
This commit is contained in:
parent
61d8a73f4c
commit
d0cc97a4cf
|
@ -10156,13 +10156,13 @@ void Tokenizer::prepareTernaryOpForAST()
|
||||||
unsigned int depth = 0;
|
unsigned int depth = 0;
|
||||||
Token* tok2 = tok->next();
|
Token* tok2 = tok->next();
|
||||||
for (; tok2; tok2 = tok2->next()) {
|
for (; tok2; tok2 = tok2->next()) {
|
||||||
if (tok2->link() && Token::Match(tok2, "{|[|("))
|
if (tok2->link() && Token::Match(tok2, "[|(|<"))
|
||||||
tok2 = tok2->link();
|
tok2 = tok2->link();
|
||||||
else if (tok2->str() == ":") {
|
else if (tok2->str() == ":") {
|
||||||
if (depth == 0)
|
if (depth == 0)
|
||||||
break;
|
break;
|
||||||
depth--;
|
depth--;
|
||||||
} else if (tok2->str() == ";" || tok2->link())
|
} else if (tok2->str() == ";" || (tok2->link() && tok2->str() != "{" && tok2->str() != "}"))
|
||||||
break;
|
break;
|
||||||
else if (tok2->str() == ",")
|
else if (tok2->str() == ",")
|
||||||
paranthesesNeeded = true;
|
paranthesesNeeded = true;
|
||||||
|
|
|
@ -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("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("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=\"\""));
|
||||||
ASSERT_EQUALS("a\'\'=", testAst("a=\'\'"));
|
ASSERT_EQUALS("a\'\'=", testAst("a=\'\'"));
|
||||||
|
|
Loading…
Reference in New Issue