Richard Smith 2a3b86c157 Fix rejects-valid when referencing an implicit operator== from within a
templated class.

When a defaulted operator<=> results in the injection of a defaulted
operator==, that operator== can be named by unqualified name within the
same class, even if the class is templated. To make this work, perform
the transform from defaulted operator<=> to defaulted operator== in the
template definition context instead of the template instantiation
context.

This results in our substituting into a declaration from a context where
we don't have a full list of template arguments (or indeed any), for
which we are now more careful to not spuriously instantiate declarations
that are not dependent on the arguments we're substituting.
2020-06-22 20:19:20 -07:00

11 lines
272 B
C++

// RUN: %clang_cc1 -std=c++20 -verify %s
// expected-no-diagnostics
namespace SpaceshipImpliesEq {
template<typename T> struct A {
int operator<=>(const A&) const = default;
constexpr bool f() { return operator==(*this); }
};
static_assert(A<int>().f());
}