[clang] [Clang] Check explicit object parameter for defaulted operators properly (PR #100419)
Mital Ashok via cfe-commits
cfe-commits at lists.llvm.org
Wed Jul 24 12:03:59 PDT 2024
================
@@ -7617,9 +7617,13 @@ bool Sema::CheckExplicitlyDefaultedSpecialMember(CXXMethodDecl *MD,
// parameter is of (possibly different) type “reference to C”,
// in which case the type of F1 would differ from the type of F2
// in that the type of F1 has an additional parameter;
- if (!Context.hasSameType(
- ThisType.getNonReferenceType().getUnqualifiedType(),
- Context.getRecordType(RD))) {
----------------
MitalAshok wrote:
That's checked somewhere later, this was operating on `ThisType`.
For an implicit object member function, `ThisType.getNonReferenceType().getUnqualifiedType()` is *always* `Context.getRecordType(RD)` (and this shouldn't fail anyways because the diagnostic emitted here is `err_defaulted_special_member_explicit_object_mismatch`)
The only difference is with explicit object member functions. The old code rejected `S& S::operator=(this int, const S&) = default;`, but accepted `S& S::operator=(this S, const S&)` since it didn't check that it was a reference.
https://github.com/llvm/llvm-project/pull/100419
More information about the cfe-commits
mailing list