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>
Wed, 17 Jun 2020 22:12:04 +0000 (15:12 -0700)
commitc7fbe2191b8b9cd64570ed3906d1bed1dd5fff8e
treedfda79bc6373c75e0f8158962aa8b95fa784dd14
parent771b7886872ec9f70b233554921c8e994e711cea
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]