From b4f32206aff029941bcf41244d98d73d831eb848 Mon Sep 17 00:00:00 2001 From: Simon Martin Date: Sat, 20 Jan 2018 14:46:09 +0100 Subject: [PATCH] Ticket #8337: Fix false positive in copy constructor detection. (#1040) --- lib/symboldatabase.cpp | 2 +- test/testclass.cpp | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/symboldatabase.cpp b/lib/symboldatabase.cpp index 92b304b00..5bf6ca913 100644 --- a/lib/symboldatabase.cpp +++ b/lib/symboldatabase.cpp @@ -924,7 +924,7 @@ void SymbolDatabase::createSymbolDatabaseCopyAndMoveConstructors() if (firstArg->type() == scope->definedType) { if (firstArg->isRValueReference()) func->type = Function::eMoveConstructor; - else if (firstArg->isReference()) + else if (firstArg->isReference() && !firstArg->isPointer()) func->type = Function::eCopyConstructor; } diff --git a/test/testclass.cpp b/test/testclass.cpp index e2dd664a1..7399f0bf8 100644 --- a/test/testclass.cpp +++ b/test/testclass.cpp @@ -287,6 +287,13 @@ private: " }\n" "};\n"); ASSERT_EQUALS("", errout.str()); + + // #8337 - False positive in copy constructor detection + checkCopyCtorAndEqOperator("struct StaticListNode {\n" + " StaticListNode(StaticListNode*& prev) : m_next(0) {}\n" + " StaticListNode* m_next;\n" + "};"); + ASSERT_EQUALS("", errout.str()); } void checkExplicitConstructors(const char code[]) {