diff --git a/lib/checkclass.cpp b/lib/checkclass.cpp index 38676b0ca..5b2320ee3 100644 --- a/lib/checkclass.cpp +++ b/lib/checkclass.cpp @@ -57,6 +57,10 @@ void CheckClass::constructors() for (std::size_t i = 0; i < classes; ++i) { const Scope * scope = symbolDatabase->classAndStructScopes[i]; + // skip forward declarations + if (scope->isForwardDeclaration()) + continue; + // don't check uninstantiated template classes if (scope->classDef->strAt(-1) == ">") continue; diff --git a/test/testclass.cpp b/test/testclass.cpp index 40c01cc60..95a330273 100644 --- a/test/testclass.cpp +++ b/test/testclass.cpp @@ -51,6 +51,7 @@ private: TEST_CASE(noConstructor4); TEST_CASE(noConstructor5); TEST_CASE(noConstructor6); // ticket #4386 + TEST_CASE(noConstructor7); // ticket #4391 TEST_CASE(operatorEq1); TEST_CASE(operatorEq2); @@ -1896,6 +1897,13 @@ private: ASSERT_EQUALS("", errout.str()); } + void noConstructor7() { + // ticket #4391 + checkNoConstructor("short bar;\n" + "class foo;\n"); + ASSERT_EQUALS("", errout.str()); + } + void checkNoMemset(const char code[]) { // Clear the error log errout.str("");