Skip to content
Merged
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
2 changes: 1 addition & 1 deletion gui/codeeditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion gui/codeeditor.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class Highlighter : public QSyntaxHighlighter {
RuleRole ruleRole;
};

void applyFormat(HighlightingRule &rule);
void applyFormat(HighlightingRule &rule) const;

QList<HighlightingRule> mHighlightingRules;
QList<HighlightingRule> mHighlightingRulesWithSymbols;
Expand Down
4 changes: 4 additions & 0 deletions lib/checkclass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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->function() || tok->type() || tok->enumerator())
return false;

for (const Variable& var : scope->varlist) {
if (var.name() == tok->str()) {
Expand Down
31 changes: 31 additions & 0 deletions test/testclass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -6785,6 +6786,36 @@ 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());

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
Expand Down
Loading