diff mbox

C++ PATCH for c++/63528 (variadic variable template)

Message ID 543EB1E4.9090805@redhat.com
State New
Headers show

Commit Message

Jason Merrill Oct. 15, 2014, 5:41 p.m. UTC
We were never calling coerce_template_parms for arguments to a variable 
template, which meant we weren't packing arguments into an argument 
pack, so tsubst_pack_expansion gave up.

Tested x86_64-pc-linux-gnu, applying to trunk.
diff mbox

Patch

commit 7e029731a4b77a1c54982e9922ff09219c46cc4b
Author: Jason Merrill <jason@redhat.com>
Date:   Wed Oct 15 13:20:58 2014 -0400

    	PR c++/63528
    	* pt.c (lookup_template_variable): Call coerce_template_parms.

diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 390e63e..2cf10f4 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -7993,6 +7993,10 @@  lookup_template_variable (tree templ, tree arglist)
     type = unknown_type_node;
   else
     type = TREE_TYPE (templ);
+  tsubst_flags_t complain = tf_warning_or_error;
+  tree parms = INNERMOST_TEMPLATE_PARMS (DECL_TEMPLATE_PARMS (templ));
+  arglist = coerce_template_parms (parms, arglist, templ, complain,
+				   /*req_all*/true, /*use_default*/true);
   return build2 (TEMPLATE_ID_EXPR, type, templ, arglist);
 }
 
diff --git a/gcc/testsuite/g++.dg/cpp1y/var-templ14.C b/gcc/testsuite/g++.dg/cpp1y/var-templ14.C
new file mode 100644
index 0000000..c3c50d1
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp1y/var-templ14.C
@@ -0,0 +1,15 @@ 
+// PR c++/63528
+// { dg-do compile { target c++14 } }
+
+template<class...>
+struct X
+{
+  constexpr static bool value = true;
+};
+
+static_assert(X<int>::value, "");
+
+template <class... Args>
+constexpr bool X_v = X<Args...>::value;
+
+static_assert(X_v<int>, "");