diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 5922b443b..fc188b45b 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -2404,9 +2404,15 @@ static void setVarIdStructMembers(Token **tok1, static const Token * findInitListEndToken(const Token *tok) { - if (!Token::simpleMatch(tok, ") :")) + if (!Token::Match(tok, ") noexcept|:") && !Token::simpleMatch(tok, "noexcept :")) return nullptr; + if (tok->strAt(1) != ":") { + tok = tok->next(); + if (tok->strAt(1) == "(") + tok = tok->linkAt(1); + } + tok = tok->tokAt(2); while (tok) { diff --git a/test/testvarid.cpp b/test/testvarid.cpp index 5ddf73102..26e5cb504 100644 --- a/test/testvarid.cpp +++ b/test/testvarid.cpp @@ -1633,6 +1633,28 @@ private: "3: A ( int x@2 ) : x@1 ( x@2 ) { }\n" "4: } ;\n", tokenize(code4)); + + const char code5[] = "class A {\n" + " A(int x) noexcept : x(x) {}\n" + " int x;\n" + "};"; + ASSERT_EQUALS("\n\n##file 0\n" + "1: class A {\n" + "2: A ( int x@1 ) noexcept : x@2 ( x@1 ) { }\n" + "3: int x@2 ;\n" + "4: } ;\n", + tokenize(code5)); + + const char code6[] = "class A {\n" + " A(int x) noexcept(true) : x(x) {}\n" + " int x;\n" + "};"; + ASSERT_EQUALS("\n\n##file 0\n" + "1: class A {\n" + "2: A ( int x@1 ) noexcept ( true ) : x@2 ( x@1 ) { }\n" + "3: int x@2 ;\n" + "4: } ;\n", + tokenize(code6)); } void varid_operator() {