Skip to content

Commit

Permalink
Fix #11411 FP selfInitialization after initialization of previous mem…
Browse files Browse the repository at this point in the history
…ber from initializer list
  • Loading branch information
chrchr-github committed Jul 13, 2023
1 parent c0bd9f8 commit 090e64b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/tokenize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4496,7 +4496,7 @@ void Tokenizer::setVarIdPass1()

// parse anonymous namespaces as part of the current scope
if (!Token::Match(startToken->previous(), "union|struct|enum|namespace {") &&
!(initlist && Token::Match(startToken->previous(), "%name%|>|>>") && Token::Match(startToken->link(), "} ,|{"))) {
!(initlist && Token::Match(startToken->previous(), "%name%|>|>>|(") && Token::Match(startToken->link(), "} ,|{|)"))) {

if (tok->str() == "{") {
bool isExecutable;
Expand Down
12 changes: 12 additions & 0 deletions test/testvarid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3460,6 +3460,18 @@ class TestVarID : public TestFixture {
"5: }\n"
"6: } ;\n";
ASSERT_EQUALS(expected, tokenize(code));

const char code2[] = "struct S {\n" // #11411
" std::vector<int> v;\n"
" int i;\n"
" S(int i) : v({ 0 }), i(i) {}\n"
"};";
const char expected2[] = "1: struct S {\n"
"2: std :: vector < int > v@1 ;\n"
"3: int i@2 ;\n"
"4: S ( int i@3 ) : v@1 ( { 0 } ) , i@2 ( i@3 ) { }\n"
"5: } ;\n";
ASSERT_EQUALS(expected2, tokenize(code2));
}

void varidclass18() {
Expand Down

0 comments on commit 090e64b

Please sign in to comment.