Fix rejects-valid when referencing an implicit operator== from within a
authorRichard Smith <richard@metafoo.co.uk>
Wed, 17 Jun 2020 21:06:11 +0000 (14:06 -0700)
committerRichard Smith <richard@metafoo.co.uk>
Tue, 23 Jun 2020 03:19:20 +0000 (20:19 -0700)
commit2a3b86c157166f3b15f718443334ab0e27b40592
treefa688802d06285d75f9d914729cbada7981f93a8
parent6bb4fc93c2fd7f63c7ed430928d1b85bfd4b3d79
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.
clang/include/clang/AST/DeclBase.h
clang/include/clang/Sema/Template.h
clang/lib/AST/DeclBase.cpp
clang/lib/Sema/SemaDecl.cpp
clang/lib/Sema/SemaDeclCXX.cpp
clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
clang/test/PCH/cxx2a-defaulted-comparison.cpp
clang/test/SemaTemplate/defaulted.cpp [new file with mode: 0644]