From 4cf5cc2ce4829212f6719ad227250b339c8daec9 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Sun, 8 Sep 2024 23:28:08 +0200 Subject: [PATCH] Fix #13070 FP uninitMemberVar for method -- parameter pack + namespace confusion (regression) (#6772) --- lib/tokenize.cpp | 2 +- test/testvarid.cpp | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index d542db04100..8b72b65c7ee 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -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; diff --git a/test/testvarid.cpp b/test/testvarid.cpp index 222906177d7..6524f0c788c 100644 --- a/test/testvarid.cpp +++ b/test/testvarid.cpp @@ -2532,6 +2532,26 @@ class TestVarID : public TestFixture { "3: int a@2 ; int & b@3 ;\n" "4: } ;\n", tokenize(code11)); + + const char code12[] = "template\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() {