diff --git a/lib/symboldatabase.cpp b/lib/symboldatabase.cpp index 9b42b799405..c0af3ff723b 100644 --- a/lib/symboldatabase.cpp +++ b/lib/symboldatabase.cpp @@ -1203,7 +1203,7 @@ void SymbolDatabase::createSymbolDatabaseSetFunctionPointers(bool firstPass) tok->function(function); - if (tok->strAt(1) != "(") + if (!function->isConstructor() && tok->strAt(1) != "(") const_cast(function)->functionPointerUsage = tok; } } diff --git a/test/testother.cpp b/test/testother.cpp index 54676cc6814..bb266e3074d 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -4150,6 +4150,16 @@ class TestOther : public TestFixture { " S s2{ cb };\n" "}\n"); ASSERT_EQUALS("[test.cpp:6:11] -> [test.cpp:2:21]: (performance) Function parameter 's' should be passed by const reference. However it seems that 'cb' is a callback function. [passedByValueCallback]\n", errout_str()); + + check("struct S {\n" // #14696 + " explicit S(std::string s = {}) {}\n" + "};\n" + "struct T {\n" + " explicit T(std::string* s = {}) {}\n" + "};\n"); + ASSERT_EQUALS("[test.cpp:2:28]: (performance) Function parameter 's' should be passed by const reference. [passedByValue]\n" + "[test.cpp:5:29]: (style) Parameter 's' can be declared as pointer to const [constParameterPointer]\n", + errout_str()); } void constPointer() {