Tokenizer::simplifyComma: dont simplify comma in '=(struct s){...}'
This commit is contained in:
parent
4175902e36
commit
bdf16b1157
|
@ -7912,12 +7912,17 @@ void Tokenizer::simplifyComma()
|
||||||
|
|
||||||
if (!tok)
|
if (!tok)
|
||||||
syntaxError(nullptr); // invalid code like in #4195
|
syntaxError(nullptr); // invalid code like in #4195
|
||||||
if (Token::Match(tok, "(|[") ||
|
|
||||||
(tok->str() == "{" && tok->previous() && tok->previous()->str() == "=")) {
|
if (Token::Match(tok, "(|[") || Token::Match(tok->previous(), "%name%|= {")) {
|
||||||
tok = tok->link();
|
tok = tok->link();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Token::simpleMatch(tok, "= (") && Token::simpleMatch(tok->linkAt(1), ") {")) {
|
||||||
|
tok = tok->linkAt(1)->linkAt(1);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
// Skip unhandled template specifiers..
|
// Skip unhandled template specifiers..
|
||||||
if (tok->link() && tok->str() == "<")
|
if (tok->link() && tok->str() == "<")
|
||||||
tok = tok->link();
|
tok = tok->link();
|
||||||
|
|
|
@ -1966,6 +1966,12 @@ private:
|
||||||
"}";
|
"}";
|
||||||
ASSERT_EQUALS(expected, tok(code));
|
ASSERT_EQUALS(expected, tok(code));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
const char code[] = "tr = (struct reg){ .a = (1), .c = (2) };";
|
||||||
|
const char expected[] = "tr = ( struct reg ) { . a = 1 , . c = 2 } ;";
|
||||||
|
ASSERT_EQUALS(expected, tok(code));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void simplifyConditionOperator() {
|
void simplifyConditionOperator() {
|
||||||
|
|
Loading…
Reference in New Issue