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 @@ -8626,8 +8626,7 @@ const ParmVarDecl *KnownParm = nullptr; for (const ParmVarDecl *Param : FD->parameters()) { QualType ParmTy = Param->getType(); - if (ParmTy->isDependentType()) - continue; + if (!KnownParm) { auto CTy = ParmTy; // Is it `T const &`? diff --git a/clang/test/CXX/class/class.compare/class.compare.default/p1.cpp b/clang/test/CXX/class/class.compare/class.compare.default/p1.cpp --- a/clang/test/CXX/class/class.compare/class.compare.default/p1.cpp +++ b/clang/test/CXX/class/class.compare/class.compare.default/p1.cpp @@ -27,6 +27,16 @@ bool operator==(const A&) const = default; // expected-error {{comparison operator template cannot be defaulted}} }; +template struct D { + C i; + friend bool operator==(const D&, D) = default; // expected-error {{must have the same type}} + friend bool operator>(D, const D&) = default; // expected-error {{must have the same type}} + friend bool operator<(const D&, const D&) = default; + friend bool operator<=(D, D) = default; + + bool operator!=(D) const = default; // expected-error {{invalid parameter type for defaulted equality comparison operator}} +}; + template struct Dependent { using U = typename T::type; bool operator==(U) const = default; // expected-error {{found 'U'}}