[PATCH] D97990: [clang] Always provide relevant subobject for 'no viable comparison'
Matheus Izvekov via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Mar 4 16:30:52 PST 2021
mizvekov created this revision.
mizvekov requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
Diagnostics for defaulted no viable not-equal and relational operators
where not providing relevant subobject in diagnostics, unlike the cases
for equal and three-way operators.
This patch changes it so that it is provided for all cases.
Signed-off-by: Matheus Izvekov <mizvekov at gmail.com>
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D97990
Files:
clang/lib/Sema/SemaDeclCXX.cpp
clang/test/CXX/class/class.compare/class.compare.default/p2.cpp
clang/test/CXX/class/class.compare/class.eq/p2.cpp
Index: clang/test/CXX/class/class.compare/class.eq/p2.cpp
===================================================================
--- clang/test/CXX/class/class.compare/class.eq/p2.cpp
+++ 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 at -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 at -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 at -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<typename T> struct X {
Index: clang/test/CXX/class/class.compare/class.compare.default/p2.cpp
===================================================================
--- clang/test/CXX/class/class.compare/class.compare.default/p2.cpp
+++ 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 at -1 {{because there is no viable comparison function}}
};
struct B1 {
Index: clang/lib/Sema/SemaDeclCXX.cpp
===================================================================
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ 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;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D97990.328335.patch
Type: text/x-patch
Size: 2774 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210305/5784f148/attachment-0001.bin>
More information about the cfe-commits
mailing list