Add test for PR50039.
authorRichard Smith <richard@metafoo.co.uk>
Wed, 12 May 2021 00:34:14 +0000 (17:34 -0700)
committerRichard Smith <richard@metafoo.co.uk>
Wed, 12 May 2021 00:35:34 +0000 (17:35 -0700)
I believe Clang's behavior is correct according to the standard here,
but this is an unusual situation for which we had no test coverage, so
I'm adding some.

clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp

index c42fda7..ad9cfc7 100644 (file)
@@ -292,3 +292,16 @@ namespace Predefined {
     Y<B{__func__[0]}>(); // expected-error {{reference to subobject of predefined '__func__' variable}}
   }
 }
+
+namespace DependentCTAD {
+  template<auto> struct A {};
+  template<template<typename> typename T, T V> void f(A<V>); // expected-note {{couldn't infer template argument 'T'}}
+  template<typename T> struct B { constexpr B(T) {} };
+
+  void g() {
+    // PR50039: Note that we could in principle deduce T here, but the language
+    // deduction rules don't support that.
+    f(A<B(0)>()); // expected-error {{no matching function}}
+    f<B>(A<B(0)>()); // OK
+  }
+}