diff --git a/lib/astutils.cpp b/lib/astutils.cpp index 3652eefbe0d..94307ab276f 100644 --- a/lib/astutils.cpp +++ b/lib/astutils.cpp @@ -2196,7 +2196,7 @@ T* getTokenArgumentFunctionImpl(T* tok, int& argn) parent = parent->astParent(); // passing variable to subfunction? - if (Token::Match(parent, "[(,{]")) + if (Token::Match(parent, "[[(,{]")) ; else if (Token::simpleMatch(parent, ":")) { while (Token::Match(parent, "[?:]")) diff --git a/test/testother.cpp b/test/testother.cpp index 91d1beef558..3a366df4474 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -3754,6 +3754,13 @@ class TestOther : public TestFixture { " p = q;\n" "}\n"); ASSERT_EQUALS("", errout.str()); + + check("struct S { int a[1]; };\n" + "void f(S* s) {\n" + " if (s->a[0]) {}\n" + "}\n"); + ASSERT_EQUALS("[test.cpp:2]: (style) Parameter 's' can be declared as pointer to const\n", + errout.str()); } void switchRedundantAssignmentTest() {