diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index e06f58023d6..37d52e41dde 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -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; diff --git a/test/testvarid.cpp b/test/testvarid.cpp index 1fdd495e782..e0ffc150020 100644 --- a/test/testvarid.cpp +++ b/test/testvarid.cpp @@ -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 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() {