Author: Richard Smith Date: 2020-10-18T14:15:12-07:00 New Revision: 094e9f4779eb9b5c6a49014f2f80b8cbb833572f
URL: https://github.com/llvm/llvm-project/commit/094e9f4779eb9b5c6a49014f2f80b8cbb833572f DIFF: https://github.com/llvm/llvm-project/commit/094e9f4779eb9b5c6a49014f2f80b8cbb833572f.diff LOG: PR47893: Synthesis of a comparison operator from an 'operator<=>' inherits the SFINAEness of its enclosing context. Added: Modified: clang/lib/Sema/SemaTemplateInstantiate.cpp clang/test/SemaCXX/cxx2a-three-way-comparison.cpp Removed: ################################################################################ diff --git a/clang/lib/Sema/SemaTemplateInstantiate.cpp b/clang/lib/Sema/SemaTemplateInstantiate.cpp index 92a887964401..67ba2b87e40e 100644 --- a/clang/lib/Sema/SemaTemplateInstantiate.cpp +++ b/clang/lib/Sema/SemaTemplateInstantiate.cpp @@ -856,6 +856,7 @@ Optional<TemplateDeductionInfo *> Sema::isSFINAEContext() const { case CodeSynthesisContext::DefaultTemplateArgumentInstantiation: case CodeSynthesisContext::PriorTemplateArgumentSubstitution: case CodeSynthesisContext::DefaultTemplateArgumentChecking: + case CodeSynthesisContext::RewritingOperatorAsSpaceship: // A default template argument instantiation and substitution into // template parameters with arguments for prior parameters may or may // not be a SFINAE context; look further up the stack. @@ -874,7 +875,6 @@ Optional<TemplateDeductionInfo *> Sema::isSFINAEContext() const { case CodeSynthesisContext::DeclaringSpecialMember: case CodeSynthesisContext::DeclaringImplicitEqualityComparison: case CodeSynthesisContext::DefiningSynthesizedFunction: - case CodeSynthesisContext::RewritingOperatorAsSpaceship: case CodeSynthesisContext::InitializingStructuredBinding: case CodeSynthesisContext::MarkingClassDllexported: // This happens in a context unrelated to template instantiation, so diff --git a/clang/test/SemaCXX/cxx2a-three-way-comparison.cpp b/clang/test/SemaCXX/cxx2a-three-way-comparison.cpp index 29ae95066e27..353360e052bb 100644 --- a/clang/test/SemaCXX/cxx2a-three-way-comparison.cpp +++ b/clang/test/SemaCXX/cxx2a-three-way-comparison.cpp @@ -31,3 +31,12 @@ struct B { }; int &r = B().operator<=>(0); + +namespace PR47893 { + struct A { + void operator<=>(const A&) const; + }; + template<typename T> auto f(T a, T b) -> decltype(a < b) = delete; + int &f(...); + int &r = f(A(), A()); +} _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits