Index: include/clang/Basic/DiagnosticSemaKinds.td =================================================================== --- include/clang/Basic/DiagnosticSemaKinds.td +++ include/clang/Basic/DiagnosticSemaKinds.td @@ -1466,6 +1466,7 @@ "type %1 of the object being destroyed">; def note_destructor_type_here : Note< "type %0 is declared here">; +def note_destructor_here : Note<"destructor is declared here">; def err_destructor_template : Error< "destructor cannot be declared as a template">; Index: lib/Sema/SemaDeclCXX.cpp =================================================================== --- lib/Sema/SemaDeclCXX.cpp +++ lib/Sema/SemaDeclCXX.cpp @@ -5570,7 +5570,16 @@ if (DiagKind == 1) S.NoteDeletedFunction(Decl); - // FIXME: Explain inaccessibility if DiagKind == 3. + if (DiagKind == 3) { + // Explain the reasons of inaccessibility. + if (Field) { + if (CXXRecordDecl *C = Field->getType()->getAsCXXRecordDecl()) { + CXXDestructorDecl *D = S.LookupDestructor(C); + if (D && !D->isImplicit()) + S.Diag(D->getLocStart(), diag::note_destructor_here); + } + } + } } return true; Index: test/CXX/special/class.copy/implicit-move.cpp =================================================================== --- test/CXX/special/class.copy/implicit-move.cpp +++ test/CXX/special/class.copy/implicit-move.cpp @@ -84,7 +84,7 @@ PrivateDestructor(const PrivateDestructor &) noexcept(false); PrivateDestructor(PrivateDestructor &&) noexcept; private: - ~PrivateDestructor() noexcept; + ~PrivateDestructor() noexcept; // expected-note{{destructor is declared here}} }; struct InheritsPrivateDestructor : PrivateDestructor {}; // expected-note{{base class 'PrivateDestructor' has an inaccessible destructor}} Index: test/CXX/special/class.copy/p11.0x.copy.cpp =================================================================== --- test/CXX/special/class.copy/p11.0x.copy.cpp +++ test/CXX/special/class.copy/p11.0x.copy.cpp @@ -97,7 +97,7 @@ // a destructor that is deleted or inaccessible struct NoAccessDtor { private: - ~NoAccessDtor(); + ~NoAccessDtor(); // expected-note {{destructor is declared here}} friend struct HasAccessDtor; }; Index: test/CXX/special/class.copy/p11.0x.move.cpp =================================================================== --- test/CXX/special/class.copy/p11.0x.move.cpp +++ test/CXX/special/class.copy/p11.0x.move.cpp @@ -109,7 +109,7 @@ struct NoAccessDtor { NoAccessDtor(NoAccessDtor&&); // expected-note{{copy constructor is implicitly deleted because 'NoAccessDtor' has a user-declared move constructor}} private: - ~NoAccessDtor(); + ~NoAccessDtor(); // expected-note{{destructor is declared here}} friend struct HasAccessDtor; }; Index: test/CXX/special/class.ctor/p5-0x.cpp =================================================================== --- test/CXX/special/class.ctor/p5-0x.cpp +++ test/CXX/special/class.ctor/p5-0x.cpp @@ -5,7 +5,7 @@ struct DeletedDefCtor { DeletedDefCtor() = delete; DeletedDefCtor(int); }; // expected-note {{explicitly marked deleted here}} class PrivateDefCtor { PrivateDefCtor() = default; public: PrivateDefCtor(int); }; struct DeletedDtor { ~DeletedDtor() = delete; }; // expected-note 4{{explicitly marked deleted here}} -class PrivateDtor { ~PrivateDtor() = default; }; +class PrivateDtor { ~PrivateDtor() = default; }; // expected-note 2{{destructor is declared here}} class Friend { Friend() = default; ~Friend() = default; friend struct NotDeleted6c; Index: test/CXX/special/class.dtor/p5-0x.cpp =================================================================== --- test/CXX/special/class.dtor/p5-0x.cpp +++ test/CXX/special/class.dtor/p5-0x.cpp @@ -7,7 +7,7 @@ ~DeletedDtor() = delete; // expected-note 5 {{deleted here}} }; class InaccessibleDtor { - ~InaccessibleDtor() = default; + ~InaccessibleDtor() = default; // expected-note 2 {{destructor is declared here}} }; // A defaulted destructor for a class X is defined as deleted if: Index: test/SemaCXX/defaulted-private-dtor.cpp =================================================================== --- test/SemaCXX/defaulted-private-dtor.cpp +++ test/SemaCXX/defaulted-private-dtor.cpp @@ -2,7 +2,7 @@ class BadDtor { // A private, but nonetheless trivial, destructor. - ~BadDtor() = default; // expected-note 9{{here}} + ~BadDtor() = default; // expected-note 10{{here}} friend class K; }; void f() {