diff --git a/cli/signalhandler.cpp b/cli/signalhandler.cpp index c87822454ae..88864efd743 100644 --- a/cli/signalhandler.cpp +++ b/cli/signalhandler.cpp @@ -108,7 +108,7 @@ static const Signalmap_t listofsignals = { * but when ending up here something went terribly wrong anyway. * And all which is left is just printing some information and terminate. */ -static void CppcheckSignalHandler(int signo, siginfo_t * info, void * context) +static void CppcheckSignalHandler(int signo, siginfo_t * info, void * context) // cppcheck-suppress constParameterCallback - info can be const { int type = -1; pid_t killid; diff --git a/lib/astutils.cpp b/lib/astutils.cpp index 2d53ef0b0c1..e1a47f22b3c 100644 --- a/lib/astutils.cpp +++ b/lib/astutils.cpp @@ -1084,7 +1084,7 @@ bool isAliasOf(const Token* tok, const Token* expr, nonneg int* indirect) r = findAstNode(expr, [&](const Token* childTok) { if (childTok->exprId() == 0) return false; - if (ref.token != tok && expr->exprId() == childTok->exprId()) { + if (ref.token != tok && expr->exprId() == childTok->exprId() && ref.token->isUnaryOp("*") && expr->exprId() == ref.token->astOperand1()->exprId()) { if (indirect) *indirect = 0; return true; diff --git a/lib/valueflow.cpp b/lib/valueflow.cpp index bf732566fff..f7e057da58f 100644 --- a/lib/valueflow.cpp +++ b/lib/valueflow.cpp @@ -4101,7 +4101,7 @@ static bool intersects(const C1& c1, const C2& c2) return false; } -static void valueFlowAfterAssign(TokenList &tokenlist, +static void valueFlowAfterAssign(const TokenList &tokenlist, const SymbolDatabase& symboldatabase, ErrorLogger &errorLogger, const Settings &settings, diff --git a/test/testother.cpp b/test/testother.cpp index 53f14c2a31d..86d3dee2786 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -4749,6 +4749,18 @@ class TestOther : public TestFixture { " return [](int* p) { return *p; }(&i);\n" "}\n"); ASSERT_EQUALS("[test.cpp:3:20]: (style) Parameter 'p' can be declared as pointer to const [constParameterPointer]\n", errout_str()); + + check("struct S {\n" // #14571 + " char* c;\n" + "};\n" + "struct T {\n" + " S s;\n" + "};\n" + "void f(std::string* p, T& t) {\n" + " S& r = t.s;\n" + " strcpy(r.c, p->c_str());\n" + "}\n"); + ASSERT_EQUALS("[test.cpp:7:21]: (style) Parameter 'p' can be declared as pointer to const [constParameterPointer]\n", errout_str()); } void constArray() {