diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 7cddb8e94..02a2ec1dc 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -62,7 +62,7 @@ const Token * Tokenizer::isFunctionHead(const Token *tok, const std::string &end tok = tok->next(); return (endsWith.find(tok->str()) != std::string::npos) ? tok : nullptr; } - if (isCPP() && Token::Match(tok, ") const| throw (")) { + if (isCPP() && Token::Match(tok, ") const| throw|noexcept (")) { tok = tok->next(); while (tok->isName()) tok = tok->next(); diff --git a/test/testvarid.cpp b/test/testvarid.cpp index 768f07593..7eca45c3a 100644 --- a/test/testvarid.cpp +++ b/test/testvarid.cpp @@ -992,6 +992,20 @@ private: "void fred ( int x@1 ) throw ( ) { } " "void wilma ( ) { x ++ ; }\n"; ASSERT_EQUALS(expected3, tokenize(code3, false, "test.cpp")); + + const char code4[] = "void fred(int x) noexcept() {}" + "void wilma() { x++; }"; + const char expected4[] = "\n\n##file 0\n1: " + "void fred ( int x@1 ) noexcept ( ) { } " + "void wilma ( ) { x ++ ; }\n"; + ASSERT_EQUALS(expected4, tokenize(code4, false, "test.cpp")); + + const char code5[] = "void fred(int x) noexcept {}" + "void wilma() { x++; }"; + const char expected5[] = "\n\n##file 0\n1: " + "void fred ( int x@1 ) noexcept { } " + "void wilma ( ) { x ++ ; }\n"; + ASSERT_EQUALS(expected5, tokenize(code5, false, "test.cpp")); } void varid57() { // #6636: new scope by {}