Fix #11411 FP selfInitialization after initialization of previous member from initializer list (#5239)

This commit is contained in:
chrchr-github 2023-07-14 10:33:05 +02:00 committed by GitHub
parent 48dd4dc33e
commit a4a29bfbc5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 1 deletions

View File

@ -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;

View File

@ -3460,6 +3460,18 @@ private:
"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() {