From ff5ede342bcfe6b2e8ac2ac8a11d055877d6e4f6 Mon Sep 17 00:00:00 2001 From: PKEuS Date: Tue, 9 Dec 2014 23:53:50 +0100 Subject: [PATCH] Fixed #6266: Support noexcept(false) --- lib/symboldatabase.cpp | 5 +++-- test/testsymboldatabase.cpp | 32 +++++++++++++++++--------------- 2 files changed, 20 insertions(+), 17 deletions(-) diff --git a/lib/symboldatabase.cpp b/lib/symboldatabase.cpp index b565e1030..2b52fa3c2 100644 --- a/lib/symboldatabase.cpp +++ b/lib/symboldatabase.cpp @@ -475,14 +475,15 @@ SymbolDatabase::SymbolDatabase(const Tokenizer *tokenizer, const Settings *setti else if (Token::Match(end, ") const| noexcept (") && (end->next()->str() == "const" ? Token::Match(end->linkAt(3), ") ;|=") : Token::Match(end->linkAt(2), ") ;|="))) { - function.isNoExcept = true; if (end->next()->str() == "const") tok = end->tokAt(3); else tok = end->tokAt(2); - if (Token::Match(tok, "= %any% ;")) { + function.isNoExcept = tok->strAt(1) != "false"; + + if (Token::Match(tok->link()->next(), "= %any% ;")) { function.isPure = true; tok = tok->tokAt(2); } diff --git a/test/testsymboldatabase.cpp b/test/testsymboldatabase.cpp index 1e973e3c4..2b98f465d 100644 --- a/test/testsymboldatabase.cpp +++ b/test/testsymboldatabase.cpp @@ -2408,9 +2408,9 @@ private: } } -#define CLASS_FUNC(x, y) const Function *x = findFunctionByName(#x, y); \ +#define CLASS_FUNC(x, y, z) const Function *x = findFunctionByName(#x, y); \ ASSERT_EQUALS(true, x != nullptr); \ - if (x) ASSERT_EQUALS(true, x->isNoExcept); + if (x) ASSERT_EQUALS(z, x->isNoExcept); void noexceptFunction3() { GET_SYMBOL_DB("struct Fred {\n" @@ -2426,6 +2426,7 @@ private: " void func10() noexcept = 0;\n" " void func11() const noexcept(true) = 0;\n" " void func12() const noexcept(true) = 0;\n" + " void func13() const noexcept(false) = 0;\n" "};"); ASSERT_EQUALS("", errout.str()); ASSERT_EQUALS(true, db != nullptr); // not null @@ -2434,18 +2435,19 @@ private: const Scope *fred = db->findScopeByName("Fred"); ASSERT_EQUALS(true, fred != nullptr); if (fred) { - CLASS_FUNC(func1, fred); - CLASS_FUNC(func2, fred); - CLASS_FUNC(func3, fred); - CLASS_FUNC(func4, fred); - CLASS_FUNC(func5, fred); - CLASS_FUNC(func6, fred); - CLASS_FUNC(func7, fred); - CLASS_FUNC(func8, fred); - CLASS_FUNC(func9, fred); - CLASS_FUNC(func10, fred); - CLASS_FUNC(func11, fred); - CLASS_FUNC(func12, fred); + CLASS_FUNC(func1, fred, true); + CLASS_FUNC(func2, fred, true); + CLASS_FUNC(func3, fred, true); + CLASS_FUNC(func4, fred, true); + CLASS_FUNC(func5, fred, true); + CLASS_FUNC(func6, fred, true); + CLASS_FUNC(func7, fred, true); + CLASS_FUNC(func8, fred, true); + CLASS_FUNC(func9, fred, true); + CLASS_FUNC(func10, fred, true); + CLASS_FUNC(func11, fred, true); + CLASS_FUNC(func12, fred, true); + CLASS_FUNC(func13, fred, false); } } } @@ -2469,7 +2471,7 @@ private: const Scope *b = db->findScopeByName("B"); ASSERT_EQUALS(true, b != nullptr); if (b) { - CLASS_FUNC(B, b); + CLASS_FUNC(B, b, true); } } }