if (ShouldDeleteSpecialMember(MD, CSM)) {
if (First) {
- MD->setDeletedAsWritten();
+ SetDeclDeleted(MD, MD->getLocation());
} else {
// C++11 [dcl.fct.def.default]p4:
// [For a] user-provided explicitly-defaulted function [...] if such a
DefaultCon->setTrivial(ClassDecl->hasTrivialDefaultConstructor());
if (ShouldDeleteSpecialMember(DefaultCon, CXXDefaultConstructor))
- DefaultCon->setDeletedAsWritten();
+ SetDeclDeleted(DefaultCon, ClassLoc);
// Note that we have declared this constructor.
++ASTContext::NumImplicitDefaultConstructorsDeclared;
// Core issue (no number): if the same inheriting constructor is
// produced by multiple base class constructors from the same base
// class, the inheriting constructor is defined as deleted.
- result.first->second.second->setDeletedAsWritten();
+ SetDeclDeleted(result.first->second.second, UsingLoc);
}
continue;
}
NewCtor->setParams(ParamDecls);
NewCtor->setInheritedConstructor(BaseCtor);
if (BaseCtor->isDeleted())
- NewCtor->setDeletedAsWritten();
+ SetDeclDeleted(NewCtor, UsingLoc);
ClassDecl->addDecl(NewCtor);
result.first->second.second = NewCtor;
Destructor->setTrivial(ClassDecl->hasTrivialDestructor());
if (ShouldDeleteSpecialMember(Destructor, CXXDestructor))
- Destructor->setDeletedAsWritten();
+ SetDeclDeleted(Destructor, ClassLoc);
// Note that we have declared this destructor.
++ASTContext::NumImplicitDestructorsDeclared;
// there is no user-declared move assignment operator, a copy assignment
// operator is implicitly declared as defaulted.
if (ShouldDeleteSpecialMember(CopyAssignment, CXXCopyAssignment))
- CopyAssignment->setDeletedAsWritten();
+ SetDeclDeleted(CopyAssignment, ClassLoc);
// Note that we have added this copy-assignment operator.
++ASTContext::NumImplicitCopyAssignmentOperatorsDeclared;
// user-declared move assignment operator, a copy constructor is implicitly
// declared as defaulted.
if (ShouldDeleteSpecialMember(CopyConstructor, CXXCopyConstructor))
- CopyConstructor->setDeletedAsWritten();
+ SetDeclDeleted(CopyConstructor, ClassLoc);
// Note that we have declared this constructor.
++ASTContext::NumImplicitCopyConstructorsDeclared;
Diag(DelLoc, diag::err_deleted_non_function);
return;
}
+
if (const FunctionDecl *Prev = Fn->getPreviousDecl()) {
// Don't consider the implicit declaration we generate for explicit
// specializations. FIXME: Do not generate these implicit declarations.
}
// If the declaration wasn't the first, we delete the function anyway for
// recovery.
+ Fn = Fn->getCanonicalDecl();
+ }
+
+ if (Fn->isDeleted())
+ return;
+
+ // See if we're deleting a function which is already known to override a
+ // non-deleted virtual function.
+ if (const CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(Fn)) {
+ bool IssuedDiagnostic = false;
+ for (CXXMethodDecl::method_iterator I = MD->begin_overridden_methods(),
+ E = MD->end_overridden_methods();
+ I != E; ++I) {
+ if (!(*MD->begin_overridden_methods())->isDeleted()) {
+ if (!IssuedDiagnostic) {
+ Diag(DelLoc, diag::err_deleted_override) << MD->getDeclName();
+ IssuedDiagnostic = true;
+ }
+ Diag((*I)->getLocation(), diag::note_overridden_virtual_function);
+ }
+ }
}
+
Fn->setDeletedAsWritten();
}
virtual void a();
virtual void b() = delete;
};
+
+struct E;
+struct F;
+struct G;
+struct H;
+struct D {
+ virtual E &operator=(const E &); // expected-note {{here}}
+ virtual F &operator=(const F &);
+ virtual G &operator=(G&&);
+ virtual H &operator=(H&&); // expected-note {{here}}
+ friend struct F;
+
+private:
+ D &operator=(const D&) = default;
+ D &operator=(D&&) = default;
+ virtual ~D(); // expected-note 2{{here}}
+};
+struct E : D {}; // expected-error {{deleted function '~E' cannot override a non-deleted function}} \
+ // expected-error {{deleted function 'operator=' cannot override a non-deleted function}}
+struct F : D {};
+// No move ctor here, because it would be deleted.
+struct G : D {}; // expected-error {{deleted function '~G' cannot override a non-deleted function}}
+struct H : D {
+ H &operator=(H&&) = default; // expected-error {{deleted function 'operator=' cannot override a non-deleted function}}
+ ~H();
+};