diff --git a/lib/symboldatabase.cpp b/lib/symboldatabase.cpp index 8eda70a45..c9cd3ecc6 100644 --- a/lib/symboldatabase.cpp +++ b/lib/symboldatabase.cpp @@ -2411,7 +2411,9 @@ void SymbolDatabase::addClassFunction(Scope **scope, const Token **tok, const To if (!func->hasBody()) { const Token *closeParen = (*tok)->next()->link(); if (closeParen) { - if (Token::Match(closeParen, ") noexcept| = default ;")) { + if (Token::Match(closeParen, ") noexcept| = default ;") || + (Token::simpleMatch(closeParen, ") noexcept (") && + Token::simpleMatch(closeParen->linkAt(2), ") = default ;"))) { func->isDefault(true); return; } @@ -2483,7 +2485,9 @@ void SymbolDatabase::addClassFunction(Scope **scope, const Token **tok, const To // normal function? const Token *closeParen = (*tok)->next()->link(); if (closeParen) { - if (Token::Match(closeParen, ") noexcept| = default ;")) { + if (Token::Match(closeParen, ") noexcept| = default ;") || + (Token::simpleMatch(closeParen, ") noexcept (") && + Token::simpleMatch(closeParen->linkAt(2), ") = default ;"))) { func->isDefault(true); return; } diff --git a/test/testsymboldatabase.cpp b/test/testsymboldatabase.cpp index 324e593f3..1497b54f9 100644 --- a/test/testsymboldatabase.cpp +++ b/test/testsymboldatabase.cpp @@ -308,6 +308,7 @@ private: TEST_CASE(symboldatabase81); // #9411 TEST_CASE(symboldatabase82); TEST_CASE(symboldatabase83); // #9431 + TEST_CASE(symboldatabase84); TEST_CASE(createSymbolDatabaseFindAllScopes1); @@ -4442,6 +4443,41 @@ private: ASSERT_EQUALS("", errout.str()); } + void symboldatabase84() { + { + const bool old = settings1.debugwarnings; + settings1.debugwarnings = true; + GET_SYMBOL_DB("struct a { a() noexcept(false); };\n" + "a::a() noexcept(false) = default;"); + settings1.debugwarnings = old; + const Scope *scope = db->findScopeByName("a"); + ASSERT(scope); + ASSERT(scope->functionList.size() == 1); + ASSERT(scope->functionList.front().name() == "a"); + ASSERT(scope->functionList.front().hasBody() == false); + ASSERT(scope->functionList.front().isConstructor() == true); + ASSERT(scope->functionList.front().isDefault() == true); + ASSERT(scope->functionList.front().isNoExcept() == false); + ASSERT_EQUALS("", errout.str()); + } + { + const bool old = settings1.debugwarnings; + settings1.debugwarnings = true; + GET_SYMBOL_DB("struct a { a() noexcept(true); };\n" + "a::a() noexcept(true) = default;"); + settings1.debugwarnings = old; + const Scope *scope = db->findScopeByName("a"); + ASSERT(scope); + ASSERT(scope->functionList.size() == 1); + ASSERT(scope->functionList.front().name() == "a"); + ASSERT(scope->functionList.front().hasBody() == false); + ASSERT(scope->functionList.front().isConstructor() == true); + ASSERT(scope->functionList.front().isDefault() == true); + ASSERT(scope->functionList.front().isNoExcept() == true); + ASSERT_EQUALS("", errout.str()); + } + } + void createSymbolDatabaseFindAllScopes1() { GET_SYMBOL_DB("void f() { union {int x; char *p;} a={0}; }"); ASSERT(db->scopeList.size() == 3);