Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 1 addition & 11 deletions lib/checkother.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
};
}
Expand Down
9 changes: 9 additions & 0 deletions test/testother.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
Loading