From 9a8e3ecdf000082d91b44bfb0cf6f9af58089391 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Mon, 16 Nov 2026 07:38:52 +0100 Subject: [PATCH 1/3] Update checkother.cpp --- lib/checkother.cpp | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/lib/checkother.cpp b/lib/checkother.cpp index 79697a2e6d7..e221accc782 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -1941,17 +1941,7 @@ static bool isConstPointerVariable(const Variable* p, const Settings& settings) namespace { struct CompareVariables { bool operator()(const Variable* a, const Variable* b) const { - const int fileA = a->nameToken()->fileIndex(); - const int fileB = b->nameToken()->fileIndex(); - if (fileA != fileB) - return fileA < fileB; - const int lineA = a->nameToken()->linenr(); - const int lineB = b->nameToken()->linenr(); - if (lineA != lineB) - return lineA < lineB; - const int columnA = a->nameToken()->column(); - const int columnB = b->nameToken()->column(); - return columnA < columnB; + return precedes(a->nameToken(), b->nameToken()); } }; } From 9248a4c0bf943c5cced2c3318538ac6933ad3342 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Mon, 16 Nov 2026 07:40:19 +0100 Subject: [PATCH 2/3] Update testother.cpp --- test/testother.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/test/testother.cpp b/test/testother.cpp index d6025e9a640..79a557bd8cb 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -5087,6 +5087,15 @@ class TestOther : public TestFixture { "void g(__attribute__((unused)) int *p) {}\n" "void h(int *p) {}\n"); ASSERT_EQUALS("[test.cpp:3:13]: (style) Parameter 'p' can be declared as pointer to const [constParameterPointer]\n", errout_str()); + + checkP("struct S { int i; };\n" // #15222 + "#define DECL_ARGS S *p, S *q\n" + "void f(DECL_ARGS) {\n" + " if (p->i == 0 && q->i == 1) {}\n" + "}\n"); + ASSERT_EQUALS("[test.cpp:3:8]: (style) Parameter 'p' can be declared as pointer to const [constParameterPointer]\n" + "[test.cpp:3:8]: (style) Parameter 'q' can be declared as pointer to const [constParameterPointer]\n", + errout_str()); } void constArray() { From 4d4380993141ffa2d370e03b3595839a2385be63 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Mon, 16 Nov 2026 08:01:53 +0100 Subject: [PATCH 3/3] Update testother.cpp --- test/testother.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/testother.cpp b/test/testother.cpp index 79a557bd8cb..085b39cfffb 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -5092,7 +5092,7 @@ class TestOther : public TestFixture { "#define DECL_ARGS S *p, S *q\n" "void f(DECL_ARGS) {\n" " if (p->i == 0 && q->i == 1) {}\n" - "}\n"); + "}\n"); ASSERT_EQUALS("[test.cpp:3:8]: (style) Parameter 'p' can be declared as pointer to const [constParameterPointer]\n" "[test.cpp:3:8]: (style) Parameter 'q' can be declared as pointer to const [constParameterPointer]\n", errout_str());