From 2900d44ff0b5037bb43b14876c7699075b1a122e Mon Sep 17 00:00:00 2001 From: Robert Reif Date: Thu, 10 Feb 2011 07:37:55 -0500 Subject: [PATCH] #2560 (False positive: The class 'Altren' does not have a constructor, because base class is in namespace.) --- lib/symboldatabase.cpp | 2 +- test/testconstructors.cpp | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/lib/symboldatabase.cpp b/lib/symboldatabase.cpp index 3ee0d272d..864b4a71c 100644 --- a/lib/symboldatabase.cpp +++ b/lib/symboldatabase.cpp @@ -583,7 +583,7 @@ bool SymbolDatabase::isFunction(const Token *tok, const Token **funcStart, const // regular function? else if (Token::Match(tok, "%var% (") && (Token::Match(tok->next()->link(), ") const| ;|{|=") || - Token::Match(tok->next()->link(), ") : %var% ("))) + Token::Match(tok->next()->link(), ") : %var% (|::"))) { *funcStart = tok; *argStart = tok->next(); diff --git a/test/testconstructors.cpp b/test/testconstructors.cpp index 2be7e5672..cd40067bc 100644 --- a/test/testconstructors.cpp +++ b/test/testconstructors.cpp @@ -60,6 +60,7 @@ private: TEST_CASE(simple2); TEST_CASE(simple3); TEST_CASE(simple4); + TEST_CASE(simple5); // ticket #2560 TEST_CASE(initvar_with_this); // BUG 2190300 TEST_CASE(initvar_if); // BUG 2190290 @@ -258,6 +259,23 @@ private: ASSERT_EQUALS("[test.cpp:7]: (warning) Member variable 'Fred::i' is not initialised in the constructor.\n", errout.str()); } + void simple5() // ticket #2560 + { + check("namespace Nsp\n" + "{\n" + " class B { };\n" + "}\n" + "class Altren : public Nsp::B\n" + "{\n" + "public:\n" + " Altren () : Nsp::B(), mValue(0)\n" + " {\n" + " }\n" + "private:\n" + " int mValue;\n" + "};"); + ASSERT_EQUALS("", errout.str()); + } void initvar_with_this() {