Skip to content

Commit 1869eca

Browse files
Fix #11488 FP unknownEvaluationOrder with designated initializers (#7049)
1 parent 5c54e72 commit 1869eca

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

lib/symboldatabase.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1734,6 +1734,8 @@ void SymbolDatabase::createSymbolDatabaseExprIds()
17341734
continue;
17351735
if (tok->isControlFlowKeyword())
17361736
continue;
1737+
if (Token::Match(tok->tokAt(-1), ". %name%") && Token::Match(tok->tokAt(-2), "[{,]")) // designated initializers
1738+
continue;
17371739

17381740
if (Token::Match(tok, "%name% <") && tok->linkAt(1)) {
17391741
tok->exprId(id);

test/testvarid.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,7 @@ class TestVarID : public TestFixture {
252252
TEST_CASE(exprid10);
253253
TEST_CASE(exprid11);
254254
TEST_CASE(exprid12);
255+
TEST_CASE(exprid13);
255256

256257
TEST_CASE(structuredBindings);
257258
}
@@ -4334,6 +4335,23 @@ class TestVarID : public TestFixture {
43344335
ASSERT_EQUALS(exp, tokenizeExpr(code));
43354336
}
43364337

4338+
void exprid13()
4339+
{
4340+
const char code[] = "struct S { int s; };\n" // #11488
4341+
"struct T { struct S s; };\n"
4342+
"struct U { struct T t; };\n"
4343+
"void f() {\n"
4344+
" struct U u = { .t = { .s = { .s = 1 } } };\n"
4345+
"}\n";
4346+
const char* exp = "1: struct S { int s ; } ;\n"
4347+
"2: struct T { struct S s ; } ;\n"
4348+
"3: struct U { struct T t ; } ;\n"
4349+
"4: void f ( ) {\n"
4350+
"5: struct U u@4 ; u@4 = { .@UNIQUE t@5 = { . s = { . s = 1 } } } ;\n"
4351+
"6: }\n";
4352+
ASSERT_EQUALS(exp, tokenizeExpr(code));
4353+
}
4354+
43374355
void structuredBindings() {
43384356
const char code[] = "int foo() { auto [x,y] = xy(); return x+y; }";
43394357
ASSERT_EQUALS("1: int foo ( ) { auto [ x@1 , y@2 ] = xy ( ) ; return x@1 + y@2 ; }\n",

0 commit comments

Comments
 (0)