Skip to content

Commit f40a2d1

Browse files
committed
Report why it's deleted
1 parent 7249f9c commit f40a2d1

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10176,6 +10176,9 @@ def note_defaulted_comparison_no_viable_function_synthesized : Note<
1017610176
def note_defaulted_comparison_not_rewritten_callee : Note<
1017710177
"defaulted %0 is implicitly deleted because this non-rewritten comparison "
1017810178
"function would be the best match for the comparison">;
10179+
def note_defaulted_comparison_vector_types : Note<
10180+
"defaulted %0 is implicitly deleted because defaulted comparison of vector "
10181+
"types is not supported">;
1017910182
def note_defaulted_comparison_not_rewritten_conversion : Note<
1018010183
"defaulted %0 is implicitly deleted because a builtin comparison function "
1018110184
"using this conversion would be the best match for the comparison">;

clang/lib/Sema/SemaDeclCXX.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8653,8 +8653,15 @@ class DefaultedComparisonAnalyzer
86538653

86548654
// FIXME: If the type we deduced is a vector type, we mark the
86558655
// comparison as deleted because we don't yet support this.
8656-
if (isa<VectorType>(T))
8656+
if (isa<VectorType>(T)) {
8657+
if (Diagnose == ExplainDeleted) {
8658+
S.Diag(FD->getLocation(),
8659+
diag::note_defaulted_comparison_vector_types)
8660+
<< FD;
8661+
S.Diag(Subobj.Decl->getLocation(), diag::note_declared_at);
8662+
}
86578663
return Result::deleted();
8664+
}
86588665

86598666
if (NeedsDeducing) {
86608667
std::optional<ComparisonCategoryType> Cat =

clang/test/SemaCXX/cxx2a-three-way-comparison.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,9 @@ namespace PR44325 {
6161

6262
namespace GH137452 {
6363
struct comparable_t {
64-
__attribute__((vector_size(32))) double numbers;
64+
__attribute__((vector_size(32))) double numbers; // expected-note {{declared here}}
6565
auto operator<=>(const comparable_t& rhs) const = default; // expected-warning {{explicitly defaulted three-way comparison operator is implicitly deleted}} \
66-
expected-note {{replace 'default' with 'delete'}}
66+
expected-note {{replace 'default' with 'delete'}} \
67+
expected-note {{defaulted 'operator<=>' is implicitly deleted because defaulted comparison of vector types is not supported}}
6768
};
6869
} // namespace GH137452

0 commit comments

Comments
 (0)