diff --git a/lib/symboldatabase.cpp b/lib/symboldatabase.cpp index 5cdc96d74..4f7d7dca7 100644 --- a/lib/symboldatabase.cpp +++ b/lib/symboldatabase.cpp @@ -7094,9 +7094,10 @@ ValueType::MatchResult ValueType::matchParameter(const ValueType *call, const Va { ValueType vt; const ValueType* pvt = funcVar->valueType(); - if (pvt && funcVar->isArray()) { + if (pvt && funcVar->isArray() && !(funcVar->isStlType() && Token::simpleMatch(funcVar->typeStartToken(), "std :: array"))) { // std::array doesn't decay to a pointer vt = *pvt; - ++vt.pointer; + if (vt.pointer == 0) // don't bump array of pointers + ++vt.pointer; pvt = &vt; } ValueType::MatchResult res = ValueType::matchParameter(call, pvt); diff --git a/test/testclass.cpp b/test/testclass.cpp index c737d0528..81e6d037a 100644 --- a/test/testclass.cpp +++ b/test/testclass.cpp @@ -201,6 +201,7 @@ private: TEST_CASE(const_shared_ptr); TEST_CASE(constPtrToConstPtr); TEST_CASE(constTrailingReturnType); + TEST_CASE(staticArrayPtrOverload); TEST_CASE(initializerListOrder); TEST_CASE(initializerListUsage); @@ -6569,6 +6570,23 @@ private: ASSERT_EQUALS("", errout.str()); } + void staticArrayPtrOverload() { + checkConst("struct S {\n" + " template\n" + " void f(const std::array& sv);\n" + " template\n" + " void f(const char* const (&StrArr)[N]);\n" + "};\n" + "template\n" + "void S::f(const std::array&sv) {\n" + " const char* ptrs[N]{};\n" + " return f(ptrs);\n" + "}\n" + "template void S::f(const std::array&sv);\n" + "\n"); + ASSERT_EQUALS("", errout.str()); + } + #define checkInitializerListOrder(code) checkInitializerListOrder_(code, __FILE__, __LINE__) void checkInitializerListOrder_(const char code[], const char* file, int line) { // Clear the error log