if (decl->hasAttr<WeakRefAttr>()) continue;
if (FunctionDecl *fn = dyn_cast<FunctionDecl>(decl)) {
- if (fn->isPure() || fn->hasBody())
+ if (fn->isDefined())
continue;
} else {
if (cast<VarDecl>(decl)->hasDefinition() != VarDecl::DeclarationOnly)
}
// Keep track of used but undefined functions.
- if (!Func->isPure() && !Func->hasBody() &&
- Func->getLinkage() != ExternalLinkage) {
+ if (!Func->isDefined() && Func->getLinkage() != ExternalLinkage) {
SourceLocation &old = UndefinedInternals[Func->getCanonicalDecl()];
if (old.isInvalid()) old = Loc;
}
/// \brief Perform reference-marking and odr-use handling for a MemberExpr.
void Sema::MarkMemberReferenced(MemberExpr *E) {
+ // C++11 [basic.def.odr]p2
+ // A non-overloaded function whose name appears as a potentially-evaluated
+ // expression or a member of a set of candidate functions, if selected by
+ // overload resolution when referred to from a potentially-evaluated
+ // expression, is odr-used, unless it is a pure virtual function and its
+ // name is not explicitly qualified.
+ if (!E->hasQualifier()) {
+ if (CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(E->getMemberDecl()))
+ if (Method->isPure())
+ return;
+ }
MarkExprReferenced(*this, E->getMemberLoc(), E->getMemberDecl(), E);
}
}
} *A;
}
+
+namespace test9 {
+ namespace {
+ struct X {
+ virtual void notused() = 0;
+ virtual void used() = 0; // expected-warning {{function 'test9::<anonymous namespace>::X::used' has internal linkage but is not defined}}
+ };
+ }
+ void test(X &x) {
+ x.notused();
+ x.X::used(); // expected-note {{used here}}
+ }
+}