From 23827f6bf9c723ef61d63bd767f0af737a9233f9 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Mon, 5 Jan 2026 10:38:35 +0100 Subject: [PATCH 1/7] Update checkclass.cpp --- lib/checkclass.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/checkclass.cpp b/lib/checkclass.cpp index 2949d3c57a7..1a45932fd96 100644 --- a/lib/checkclass.cpp +++ b/lib/checkclass.cpp @@ -2292,6 +2292,10 @@ bool CheckClass::isMemberVar(const Scope *scope, const Token *tok) const if (tok->isKeyword() || tok->isStandardType()) return false; + if (tok->variable() && (tok->variable()->isArgument() || tok->variable()->isLocal())) + return false; + if (tok->type()) + return false; for (const Variable& var : scope->varlist) { if (var.name() == tok->str()) { From 202b0ba59c7e1013a7f289f1ed0cba039b3faa88 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Mon, 5 Jan 2026 10:39:47 +0100 Subject: [PATCH 2/7] Update testclass.cpp --- test/testclass.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/test/testclass.cpp b/test/testclass.cpp index 21457f15bfc..967fec56a8e 100644 --- a/test/testclass.cpp +++ b/test/testclass.cpp @@ -6785,6 +6785,22 @@ class TestClass : public TestFixture { " B::g(0);\n" "}\n"); ASSERT_EQUALS("", errout_str()); + + checkConst("struct S {\n" // #14366 + " void f();\n" + "};\n" + "struct T : U {\n" + " void g(S* s) {\n" + " s->f();\n" + " }\n" + " void h() {\n" + " S s;\n" + " s.f();\n" + " }\n" + "};\n"); + ASSERT_EQUALS("[test.cpp:5:10]: (style) Either there is a missing 'override', or the member function 'T::g' can be static. [functionStatic]\n" + "[test.cpp:8:10]: (style) Either there is a missing 'override', or the member function 'T::h' can be static. [functionStatic]\n", + errout_str()); } void const97() { // #13301 From 5bc6f53118e303694970b9a0e9dcb869404c44e8 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Mon, 5 Jan 2026 12:13:04 +0100 Subject: [PATCH 3/7] Update testclass.cpp --- test/testclass.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/testclass.cpp b/test/testclass.cpp index 967fec56a8e..16ed66abe75 100644 --- a/test/testclass.cpp +++ b/test/testclass.cpp @@ -6785,7 +6785,7 @@ class TestClass : public TestFixture { " B::g(0);\n" "}\n"); ASSERT_EQUALS("", errout_str()); - + checkConst("struct S {\n" // #14366 " void f();\n" "};\n" From 0cec176bf05087813281c09cd192d7d313124e4c Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Mon, 5 Jan 2026 12:13:54 +0100 Subject: [PATCH 4/7] Update codeeditor.cpp --- gui/codeeditor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gui/codeeditor.cpp b/gui/codeeditor.cpp index 7e7f2cbc37c..b6d88a061d3 100644 --- a/gui/codeeditor.cpp +++ b/gui/codeeditor.cpp @@ -246,7 +246,7 @@ void Highlighter::highlightBlock(const QString &text) } } -void Highlighter::applyFormat(HighlightingRule &rule) +void Highlighter::applyFormat(HighlightingRule &rule) const { switch (rule.ruleRole) { case RuleRole::Keyword: From 0dbf1f13831be41520a189c2550a5a3a4c3dc5b5 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Mon, 5 Jan 2026 12:14:34 +0100 Subject: [PATCH 5/7] Update codeeditor.h --- gui/codeeditor.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gui/codeeditor.h b/gui/codeeditor.h index 4f6d07e1e36..9508c562c41 100644 --- a/gui/codeeditor.h +++ b/gui/codeeditor.h @@ -65,7 +65,7 @@ class Highlighter : public QSyntaxHighlighter { RuleRole ruleRole; }; - void applyFormat(HighlightingRule &rule); + void applyFormat(HighlightingRule &rule) const; QList mHighlightingRules; QList mHighlightingRulesWithSymbols; From bdac846c9c6256b1750a67036749344416ae8928 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Mon, 5 Jan 2026 13:52:04 +0100 Subject: [PATCH 6/7] Update testclass.cpp --- test/testclass.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/test/testclass.cpp b/test/testclass.cpp index 16ed66abe75..46c61d41c37 100644 --- a/test/testclass.cpp +++ b/test/testclass.cpp @@ -6731,6 +6731,7 @@ class TestClass : public TestFixture { "struct S<0> {};\n" "struct D : S<150> {};\n"); // don't hang + ignore_errout(); } void const93() { // #12162 @@ -6801,6 +6802,20 @@ class TestClass : public TestFixture { ASSERT_EQUALS("[test.cpp:5:10]: (style) Either there is a missing 'override', or the member function 'T::g' can be static. [functionStatic]\n" "[test.cpp:8:10]: (style) Either there is a missing 'override', or the member function 'T::h' can be static. [functionStatic]\n", errout_str()); + + checkConst("enum E { E0 };\n" + "int f();\n" + "struct S : U {\n" + " E g() {\n" + " return E0;\n" + " }\n" + " int h() {\n" + " return f();\n" + " }\n" + "};\n"); + ASSERT_EQUALS("[test.cpp:4:7]: (style) Either there is a missing 'override', or the member function 'S::g' can be static. [functionStatic]\n" + "[test.cpp:7:9]: (style) Either there is a missing 'override', or the member function 'S::h' can be static. [functionStatic]\n", + errout_str()); } void const97() { // #13301 From 727b892ae6a7ff0017dc52c7808cc6be53301e59 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Mon, 5 Jan 2026 13:53:58 +0100 Subject: [PATCH 7/7] Update checkclass.cpp --- lib/checkclass.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/checkclass.cpp b/lib/checkclass.cpp index 1a45932fd96..11951411f8f 100644 --- a/lib/checkclass.cpp +++ b/lib/checkclass.cpp @@ -2294,7 +2294,7 @@ bool CheckClass::isMemberVar(const Scope *scope, const Token *tok) const return false; if (tok->variable() && (tok->variable()->isArgument() || tok->variable()->isLocal())) return false; - if (tok->type()) + if (tok->function() || tok->type() || tok->enumerator()) return false; for (const Variable& var : scope->varlist) {