Skip to content

Commit

Permalink
Fix #13070 FP uninitMemberVar for method -- parameter pack + namespac…
Browse files Browse the repository at this point in the history
…e confusion (regression) (#6772)
  • Loading branch information
chrchr-github authored Sep 8, 2024
1 parent ced6259 commit 4cf5cc2
Show file tree
Hide file tree
Showing 2 changed files with 21 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 @@ -4611,7 +4611,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
20 changes: 20 additions & 0 deletions test/testvarid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2532,6 +2532,26 @@ class TestVarID : public TestFixture {
"3: int a@2 ; int & b@3 ;\n"
"4: } ;\n",
tokenize(code11));

const char code12[] = "template<typename... T>\n" // # 13070
" struct S1 : T... {\n"
" constexpr S1(const T& ... p) : T{ p } {}\n"
"};\n"
"namespace p { struct S2 {}; }\n"
"struct S3 {\n"
" S3() {}\n"
" bool f(p::S2& c);\n"
"};\n";
ASSERT_EQUALS("1: template < typename ... T >\n"
"2: struct S1 : T ... {\n"
"3: constexpr S1 ( const T & ... p@1 ) : T { p@1 } { }\n"
"4: } ;\n"
"5: namespace p { struct S2 { } ; }\n"
"6: struct S3 {\n"
"7: S3 ( ) { }\n"
"8: bool f ( p :: S2 & c@2 ) ;\n"
"9: } ;\n",
tokenize(code12));
}

void varid_initListWithBaseTemplate() {
Expand Down

0 comments on commit 4cf5cc2

Please sign in to comment.