Author: Richard Smith Date: 2021-06-02T13:06:40-07:00 New Revision: 13659f48a1d7814fe893d2383acdc0b0313740a9
URL: https://github.com/llvm/llvm-project/commit/13659f48a1d7814fe893d2383acdc0b0313740a9 DIFF: https://github.com/llvm/llvm-project/commit/13659f48a1d7814fe893d2383acdc0b0313740a9.diff LOG: PR50337, PR50561: Fix determination of whether a template parameter list contains constrained parameters. Added: Modified: clang/lib/AST/DeclTemplate.cpp clang/test/SemaTemplate/concepts.cpp Removed: ################################################################################ diff --git a/clang/lib/AST/DeclTemplate.cpp b/clang/lib/AST/DeclTemplate.cpp index e5b1833a02f2..ec8b00a9eb7d 100644 --- a/clang/lib/AST/DeclTemplate.cpp +++ b/clang/lib/AST/DeclTemplate.cpp @@ -74,7 +74,8 @@ TemplateParameterList::TemplateParameterList(const ASTContext& C, ->containsUnexpandedParameterPack()) ContainsUnexpandedParameterPack = true; } - HasConstrainedParameters = TTP->hasTypeConstraint(); + if (TTP->hasTypeConstraint()) + HasConstrainedParameters = true; } else { llvm_unreachable("unexpcted template parameter type"); } diff --git a/clang/test/SemaTemplate/concepts.cpp b/clang/test/SemaTemplate/concepts.cpp index 60c8bc59d33c..c297a75dd82e 100644 --- a/clang/test/SemaTemplate/concepts.cpp +++ b/clang/test/SemaTemplate/concepts.cpp @@ -154,3 +154,18 @@ namespace NoConstantFolding { template <class T> concept C = &n + 3 - 3 == &n; // expected-error {{non-constant expression}} expected-note {{cannot refer to element 3 of non-array object}} static_assert(C<void>); // expected-note {{while checking}} } + +namespace PR50337 { + template <typename T> concept foo = true; + template <typename T> concept foo2 = foo<T> && true; + void f(foo auto, auto); + void f(foo2 auto, auto); + void g() { f(1, 2); } +} + +namespace PR50561 { + template<typename> concept C = false; + template<typename T, typename U> void f(T, U); + template<C T, typename U> void f(T, U) = delete; + void g() { f(0, 0); } +} _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits