Skip to content

Commit b9e6ace

Browse files
authored
Fix #14450: FP functionStatic (unknown function call confused with constructor) (#8397)
1 parent 182815a commit b9e6ace

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

lib/symboldatabase.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6430,7 +6430,7 @@ const Function* SymbolDatabase::findFunction(const Token* const tok) const
64306430
}
64316431
}
64326432
// Check for constructor
6433-
if (Token::Match(tok, "%name% (|{")) {
6433+
if (!Token::simpleMatch(tok->tokAt(-2), "this .") && Token::Match(tok, "%name% (|{")) {
64346434
ValueType vt = ValueType::parseDecl(tok, mSettings);
64356435
if (vt.typeScope)
64366436
return vt.typeScope->findFunction(tok, false);

test/testclass.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ class TestClass : public TestFixture {
195195
TEST_CASE(const98);
196196
TEST_CASE(const99);
197197
TEST_CASE(const100);
198+
TEST_CASE(const101);
198199

199200
TEST_CASE(const_handleDefaultParameters);
200201
TEST_CASE(const_passThisToMemberOfOtherClass);
@@ -6972,6 +6973,16 @@ class TestClass : public TestFixture {
69726973
ASSERT_EQUALS("", errout_str()); // don't crash
69736974
}
69746975

6976+
void const101() {
6977+
checkConst("struct error {\n"
6978+
" error() = default;\n"
6979+
"};\n"
6980+
"struct S : U {\n"
6981+
" int f() { return this->error(); }\n"
6982+
"};\n");
6983+
ASSERT_EQUALS("", errout_str());
6984+
}
6985+
69756986
void const_handleDefaultParameters() {
69766987
checkConst("struct Foo {\n"
69776988
" void foo1(int i, int j = 0) {\n"

0 commit comments

Comments
 (0)