From c592ccd35d25958444cf91f448a540b9d12c8be1 Mon Sep 17 00:00:00 2001 From: Robert Reif Date: Sat, 5 Feb 2011 08:59:59 +0100 Subject: [PATCH] Fixed #2547 (segmentation fault of cppcheck) --- lib/symboldatabase.cpp | 4 ++-- test/testclass.cpp | 11 +++++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/lib/symboldatabase.cpp b/lib/symboldatabase.cpp index af0dd6818..3ee0d272d 100644 --- a/lib/symboldatabase.cpp +++ b/lib/symboldatabase.cpp @@ -213,7 +213,7 @@ SymbolDatabase::SymbolDatabase(const Tokenizer *tokenizer, const Settings *setti function.isConst = true; // pure virtual function - if (Token::Match(end, ") const| = 0 ;")) + if (Token::Match(end, ") const| = %any% ;")) function.isPure = true; // count the number of constructors @@ -227,7 +227,7 @@ SymbolDatabase::SymbolDatabase(const Tokenizer *tokenizer, const Settings *setti // out of line function if (Token::Match(end, ") const| ;") || - Token::Match(end, ") const| = 0 ;")) + Token::Match(end, ") const| = %any% ;")) { // find the function implementation later tok = end->next(); diff --git a/test/testclass.cpp b/test/testclass.cpp index 0fd7f6fcd..a8cb213e1 100644 --- a/test/testclass.cpp +++ b/test/testclass.cpp @@ -190,6 +190,7 @@ private: TEST_CASE(symboldatabase9); // ticket #2525 TEST_CASE(symboldatabase10); // ticket #2537 TEST_CASE(symboldatabase11); // ticket #2539 + TEST_CASE(symboldatabase12); // ticket #2547 } // Check the operator Equal @@ -5517,6 +5518,16 @@ private: ASSERT_EQUALS("", errout.str()); } + void symboldatabase12() + { + // ticket #2547 - segmentation fault + checkConst("class foo {\n" + " void bar2 () = __null;\n" + "};\n"); + + ASSERT_EQUALS("", errout.str()); + } + }; REGISTER_TEST(TestClass)