parent
a666e31801
commit
d06f93aebf
|
@ -5470,10 +5470,14 @@ const Function* Scope::findFunction(const Token *tok, bool requireConst) const
|
|||
if (fallback2Func)
|
||||
return fallback2Func;
|
||||
|
||||
// remove pure virtual function
|
||||
matches.erase(std::remove_if(matches.begin(), matches.end(), [](const Function* m) {
|
||||
// remove pure virtual function if there is an overrider
|
||||
auto itPure = std::find_if(matches.begin(), matches.end(), [](const Function* m) {
|
||||
return m->isPure();
|
||||
}), matches.end());
|
||||
});
|
||||
if (itPure != matches.end() && std::any_of(matches.begin(), matches.end(), [&](const Function* m) {
|
||||
return m->isImplicitlyVirtual() && m != *itPure;
|
||||
}))
|
||||
matches.erase(itPure);
|
||||
|
||||
// Only one candidate left
|
||||
if (matches.size() == 1)
|
||||
|
|
|
@ -141,6 +141,7 @@ private:
|
|||
TEST_CASE(nullpointer95); // #11142
|
||||
TEST_CASE(nullpointer96); // #11416
|
||||
TEST_CASE(nullpointer97); // #11229
|
||||
TEST_CASE(nullpointer98); // #11458
|
||||
TEST_CASE(nullpointer_addressOf); // address of
|
||||
TEST_CASE(nullpointerSwitch); // #2626
|
||||
TEST_CASE(nullpointer_cast); // #4692
|
||||
|
@ -2796,6 +2797,17 @@ private:
|
|||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void nullpointer98() // #11458
|
||||
{
|
||||
check("struct S { double* d() const; };\n"
|
||||
"struct T {\n"
|
||||
" virtual void g(double* b, double* d) const = 0;\n"
|
||||
" void g(S* b) const { g(b->d(), nullptr); }\n"
|
||||
" void g(S* b, S* d) const { g(b->d(), d->d()); }\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void nullpointer_addressOf() { // address of
|
||||
check("void f() {\n"
|
||||
" struct X *x = 0;\n"
|
||||
|
|
Loading…
Reference in New Issue