When marking derived classes' virtual methods ODR-used in order to trigger

instantiation in order to permit devirtualization later in codegen, skip over
pure functions since those can't be devirtualization targets.

llvm-svn: 175116
This commit is contained in:
Nick Lewycky 2013-02-14 00:55:17 +00:00
parent 3cfba5bf13
commit b7444cd11e
2 changed files with 18 additions and 1 deletions

View File

@ -11179,7 +11179,7 @@ static void MarkExprReferenced(Sema &SemaRef, SourceLocation Loc,
if (!MostDerivedClassDecl) if (!MostDerivedClassDecl)
return; return;
CXXMethodDecl *DM = MD->getCorrespondingMethodInClass(MostDerivedClassDecl); CXXMethodDecl *DM = MD->getCorrespondingMethodInClass(MostDerivedClassDecl);
if (!DM) if (!DM || DM->isPure())
return; return;
SemaRef.MarkAnyDeclReferenced(Loc, DM, OdrUse); SemaRef.MarkAnyDeclReferenced(Loc, DM, OdrUse);
} }

View File

@ -306,3 +306,20 @@ namespace test12 {
Cls2 obj1((T7())); // expected-note {{used here}} Cls2 obj1((T7())); // expected-note {{used here}}
} }
} }
namespace test13 {
namespace {
struct X {
virtual void f() { }
};
struct Y : public X {
virtual void f() = 0;
virtual void g() {
X::f();
}
};
}
}