Skip to content

Commit fb7135e

Browse files
authored
[Clang] fixed clang frontend crash with friend class declaration and overload == (#133878)
1 parent 749c20b commit fb7135e

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

Diff for: clang/docs/ReleaseNotes.rst

+1
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,7 @@ Bug Fixes to Attribute Support
365365
Bug Fixes to C++ Support
366366
^^^^^^^^^^^^^^^^^^^^^^^^
367367

368+
- Clang now supports implicitly defined comparison operators for friend declarations. (#GH132249)
368369
- Clang now diagnoses copy constructors taking the class by value in template instantiations. (#GH130866)
369370
- Clang is now better at keeping track of friend function template instance contexts. (#GH55509)
370371
- Clang now prints the correct instantiation context for diagnostics suppressed

Diff for: clang/lib/Sema/SemaDeclCXX.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -9006,8 +9006,7 @@ bool Sema::CheckExplicitlyDefaultedComparison(Scope *S, FunctionDecl *FD,
90069006
return true;
90079007

90089008
if (llvm::none_of(RD->friends(), [&](const FriendDecl *F) {
9009-
return FD->getCanonicalDecl() ==
9010-
F->getFriendDecl()->getCanonicalDecl();
9009+
return declaresSameEntity(F->getFriendDecl(), FD);
90119010
})) {
90129011
Diag(FD->getLocation(), diag::err_defaulted_comparison_not_friend)
90139012
<< int(DCK) << int(0) << RD;

Diff for: clang/test/CXX/class/class.compare/class.compare.default/p1.cpp

+12
Original file line numberDiff line numberDiff line change
@@ -285,3 +285,15 @@ struct j {
285285
};
286286
bool j::operator==(const j &) const = default;
287287
}
288+
289+
namespace evil2 {
290+
struct k {
291+
};
292+
293+
struct l {
294+
friend bool operator==(const l& a, const l& b);
295+
friend class k;
296+
};
297+
298+
bool operator==(const l& a, const l& b) = default;
299+
}

0 commit comments

Comments
 (0)