From 6732f05b95976e6ce37bbc330189456b6c13448b Mon Sep 17 00:00:00 2001 From: Robert Reif Date: Sun, 16 Dec 2012 07:18:03 +0100 Subject: [PATCH] Fixed #4404 (Forward declared class cause false style warning about missing constructor) --- lib/symboldatabase.cpp | 8 +++++++- test/testclass.cpp | 9 +++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/lib/symboldatabase.cpp b/lib/symboldatabase.cpp index f62f57605..c0a568f06 100644 --- a/lib/symboldatabase.cpp +++ b/lib/symboldatabase.cpp @@ -1912,9 +1912,15 @@ void Scope::getVariableList() if (classStart) start = classStart->next(); - else + + // global scope + else if (className.empty()) start = check->_tokenizer->tokens(); + // forward declaration + else + return; + for (const Token *tok = start; tok; tok = tok->next()) { // end of scope? if (tok->str() == "}") { diff --git a/test/testclass.cpp b/test/testclass.cpp index 95a330273..aa02a1cb1 100644 --- a/test/testclass.cpp +++ b/test/testclass.cpp @@ -52,6 +52,7 @@ private: TEST_CASE(noConstructor5); TEST_CASE(noConstructor6); // ticket #4386 TEST_CASE(noConstructor7); // ticket #4391 + TEST_CASE(noConstructor8); // ticket #4404 TEST_CASE(operatorEq1); TEST_CASE(operatorEq2); @@ -1904,6 +1905,14 @@ private: ASSERT_EQUALS("", errout.str()); } + void noConstructor8() { + // ticket #4404 + checkNoConstructor("class LineSegment;\n" + "class PointArray { };\n" + "void* tech_ = NULL;\n"); + ASSERT_EQUALS("", errout.str()); + } + void checkNoMemset(const char code[]) { // Clear the error log errout.str("");