[clang] [clang] check deduction consistency when partial ordering function templates (PR #100692)
Matheus Izvekov via cfe-commits
cfe-commits at lists.llvm.org
Fri Aug 23 19:30:53 PDT 2024
================
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 -std=c++23 -verify %s
+
+namespace t1 {
+template<bool> struct enable_if { typedef void type; };
+template <class T> class Foo {};
+template <class X> constexpr bool check() { return true; }
+template <class X, class Enable = void> struct Bar {};
+
+template<class X> void func(Bar<X, typename enable_if<check<X>()>::type>) {}
+// expected-note at -1 {{candidate function}}
+
+template<class T> void func(Bar<Foo<T>>) {}
+// expected-note at -1 {{candidate function}}
+
+void g() {
+ func(Bar<Foo<int>>()); // expected-error {{call to 'func' is ambiguous}}
----------------
mizvekov wrote:
> can you add a similar tests where the overload are constrained (both with subsumption, and with either one having a constraint nit satisfied)
Subsumption is not checked on deduction, that's only used later during overload resolution, which we are not changing, so I am not sure that test would be relevant to this change.
Relatedly, in a callback to another discussion with @zygoloid , we currently check if deduction would produce arguments which would not satisfy the constraints, but according to the specification this should not apply to partial ordering, which we fail to do so before this patch, and this patch introduces another case where we fail to follow the rules.
https://github.com/llvm/llvm-project/pull/100692
More information about the cfe-commits
mailing list