Skip to content

Commit 4cf5cc2

Browse files
Fix #13070 FP uninitMemberVar for method -- parameter pack + namespace confusion (regression) (#6772)
1 parent ced6259 commit 4cf5cc2

2 files changed

Lines changed: 21 additions & 1 deletion

File tree

lib/tokenize.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4611,7 +4611,7 @@ void Tokenizer::setVarIdPass1()
46114611

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

46164616
if (tok->str() == "{") {
46174617
bool isExecutable;

test/testvarid.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2532,6 +2532,26 @@ class TestVarID : public TestFixture {
25322532
"3: int a@2 ; int & b@3 ;\n"
25332533
"4: } ;\n",
25342534
tokenize(code11));
2535+
2536+
const char code12[] = "template<typename... T>\n" // # 13070
2537+
" struct S1 : T... {\n"
2538+
" constexpr S1(const T& ... p) : T{ p } {}\n"
2539+
"};\n"
2540+
"namespace p { struct S2 {}; }\n"
2541+
"struct S3 {\n"
2542+
" S3() {}\n"
2543+
" bool f(p::S2& c);\n"
2544+
"};\n";
2545+
ASSERT_EQUALS("1: template < typename ... T >\n"
2546+
"2: struct S1 : T ... {\n"
2547+
"3: constexpr S1 ( const T & ... p@1 ) : T { p@1 } { }\n"
2548+
"4: } ;\n"
2549+
"5: namespace p { struct S2 { } ; }\n"
2550+
"6: struct S3 {\n"
2551+
"7: S3 ( ) { }\n"
2552+
"8: bool f ( p :: S2 & c@2 ) ;\n"
2553+
"9: } ;\n",
2554+
tokenize(code12));
25352555
}
25362556

25372557
void varid_initListWithBaseTemplate() {

0 commit comments

Comments
 (0)