diff --git a/lib/symboldatabase.cpp b/lib/symboldatabase.cpp index c9851d6e7ca..76c49b2c833 100644 --- a/lib/symboldatabase.cpp +++ b/lib/symboldatabase.cpp @@ -6430,7 +6430,7 @@ const Function* SymbolDatabase::findFunction(const Token* const tok) const } } // Check for constructor - if (Token::Match(tok, "%name% (|{")) { + if (!Token::simpleMatch(tok->tokAt(-2), "this .") && Token::Match(tok, "%name% (|{")) { ValueType vt = ValueType::parseDecl(tok, mSettings); if (vt.typeScope) return vt.typeScope->findFunction(tok, false); diff --git a/test/testclass.cpp b/test/testclass.cpp index 43ada536df2..62cf32cfba5 100644 --- a/test/testclass.cpp +++ b/test/testclass.cpp @@ -195,6 +195,7 @@ class TestClass : public TestFixture { TEST_CASE(const98); TEST_CASE(const99); TEST_CASE(const100); + TEST_CASE(const101); TEST_CASE(const_handleDefaultParameters); TEST_CASE(const_passThisToMemberOfOtherClass); @@ -6972,6 +6973,16 @@ class TestClass : public TestFixture { ASSERT_EQUALS("", errout_str()); // don't crash } + void const101() { + checkConst("struct error {\n" + " error() = default;\n" + "};\n" + "struct S : U {\n" + " int f() { return this->error(); }\n" + "};\n"); + ASSERT_EQUALS("", errout_str()); + } + void const_handleDefaultParameters() { checkConst("struct Foo {\n" " void foo1(int i, int j = 0) {\n"