Fixed #1362 (Internal error when using ?-operator and nested {})
This commit is contained in:
parent
93bb1c0174
commit
ed8f3bc806
|
@ -3406,9 +3406,27 @@ bool Tokenizer::simplifyQuestionMark()
|
||||||
// The condition is true. Delete the operator after the ":"..
|
// The condition is true. Delete the operator after the ":"..
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
const Token *end = 0;
|
||||||
|
|
||||||
|
// check the operator after the :
|
||||||
|
if (Token::simpleMatch(semicolon, ": ("))
|
||||||
|
{
|
||||||
|
end = semicolon->next()->link();
|
||||||
|
if (!Token::Match(end, ") !!."))
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
// delete the condition token and the "?"
|
// delete the condition token and the "?"
|
||||||
tok = tok->tokAt(-2);
|
tok = tok->tokAt(-2);
|
||||||
Token::eraseTokens(tok, tok->tokAt(3));
|
Token::eraseTokens(tok, tok->tokAt(3));
|
||||||
|
|
||||||
|
// delete operator after the :
|
||||||
|
if (end)
|
||||||
|
{
|
||||||
|
Token::eraseTokens(semicolon->previous(), end->next());
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
int ind = 0;
|
int ind = 0;
|
||||||
for (const Token *end = semicolon; end; end = end->next())
|
for (const Token *end = semicolon; end; end = end->next())
|
||||||
{
|
{
|
||||||
|
|
|
@ -1964,6 +1964,11 @@ private:
|
||||||
const char code[] = "int vals[] = { 0x13, 0?0x01:0x00 };";
|
const char code[] = "int vals[] = { 0x13, 0?0x01:0x00 };";
|
||||||
ASSERT_EQUALS("int * vals ; vals = { 19 , 0 } ;", tok(code));
|
ASSERT_EQUALS("int * vals ; vals = { 19 , 0 } ;", tok(code));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
const char code[] = "= 1 ? 0 : ({ 0; });";
|
||||||
|
ASSERT_EQUALS("= 0 ;", tok(code));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void calculations()
|
void calculations()
|
||||||
|
|
Loading…
Reference in New Issue