diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp --- a/clang/lib/Sema/SemaDeclCXX.cpp +++ b/clang/lib/Sema/SemaDeclCXX.cpp @@ -7857,6 +7857,13 @@ } if (Diagnose == ExplainDeleted) { + if (Subobj.Kind == DefaultedComparisonSubobject::CompleteObject) { + QualType ParamLvalType = + FD->getParamDecl(0)->getType().getNonReferenceType(); + getDerived().visitSubobjects(R, RD, ParamLvalType.getQualifiers()); + R = Result::deleted(); + break; + } S.Diag(Subobj.Loc, diag::note_defaulted_comparison_no_viable_function) << FD << Subobj.Kind << Subobj.Decl; diff --git a/clang/test/CXX/class/class.compare/class.compare.default/p2.cpp b/clang/test/CXX/class/class.compare/class.compare.default/p2.cpp --- a/clang/test/CXX/class/class.compare/class.compare.default/p2.cpp +++ b/clang/test/CXX/class/class.compare/class.compare.default/p2.cpp @@ -40,11 +40,10 @@ } struct A3 { - int &x; // expected-note {{because class 'A3' has a reference member}} + int &x; // expected-note 2{{because class 'A3' has a reference member}} bool operator==(const A3 &) const = default; // expected-warning {{implicitly deleted}} bool operator<(const A3 &) const = default; // expected-warning {{implicitly deleted}} - // expected-note@-1 {{because there is no viable comparison function}} }; struct B1 { diff --git a/clang/test/CXX/class/class.compare/class.eq/p2.cpp b/clang/test/CXX/class/class.compare/class.eq/p2.cpp --- a/clang/test/CXX/class/class.compare/class.eq/p2.cpp +++ b/clang/test/CXX/class/class.compare/class.eq/p2.cpp @@ -18,20 +18,17 @@ struct H1 { bool operator==(const H1 &) const = default; bool operator<(const H1 &) const = default; // expected-warning {{implicitly deleted}} - // expected-note@-1 {{because there is no viable comparison function}} - void (*x)(); + void (*x)(); // expected-note {{because there is no viable comparison function for member 'x'}} }; struct H2 { bool operator==(const H2 &) const = default; bool operator<(const H2 &) const = default; // expected-warning {{implicitly deleted}} - // expected-note@-1 {{because there is no viable comparison function}} - void (H2::*x)(); + void (H2::*x)(); // expected-note {{because there is no viable comparison function for member 'x'}} }; struct H3 { bool operator==(const H3 &) const = default; bool operator<(const H3 &) const = default; // expected-warning {{implicitly deleted}} - // expected-note@-1 {{because there is no viable comparison function}} - int H3::*x; + int H3::*x; // expected-note {{because there is no viable comparison function for member 'x'}} }; template struct X {