Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/tokenize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4970,7 +4970,7 @@ void Tokenizer::setVarIdPass1()
decl = false;
} else if (cpp && Token::Match(prev2, "%type% {") && Token::simpleMatch(tok2->link(), "} ;")) { // C++11 initialization style
if (tok2->link() != tok2->next() && // add value-initialized variable T x{};
(Token::Match(prev2, "do|try|else") || Token::Match(prev2->tokAt(-2), "struct|class|:")))
(Token::Match(prev2, "do|try|else") || Token::simpleMatch(prev2->tokAt(-2), ":")))
continue;
} else
decl = false;
Expand Down
5 changes: 5 additions & 0 deletions test/testvarid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3066,6 +3066,11 @@ class TestVarID : public TestFixture {
" int j{i};\n"
" }\n"
"};"));

ASSERT_EQUALS("1: struct Sx { int i@1 ; } ;\n" // #14733
"2: struct Sx sx@2 { 0 } ;\n",
tokenize("struct Sx { int i; };\n"
"struct Sx sx{ 0 }; \n"));
}

void varid_inheritedMembers() {
Expand Down
Loading