2015-05-18 Jason Merrill <jason@redhat.com>
+ * pt.c (tsubst_decl) [VAR_DECL]: Call coerce_innermost_template_parms.
+ (determine_specialization): Call coerce_template_parms.
+
DR 1391
* pt.c (type_unification_real): Check convertibility here.
(unify_one_argument): Not here.
++header_count;
if (variable_template_p (fns))
- templates = tree_cons (explicit_targs, fns, templates);
+ {
+ tree parms = INNERMOST_TEMPLATE_PARMS (DECL_TEMPLATE_PARMS (fns));
+ targs = coerce_template_parms (parms, explicit_targs, fns,
+ tf_warning_or_error,
+ /*req_all*/true, /*use_defarg*/true);
+ templates = tree_cons (targs, fns, templates);
+ }
else for (; fns; fns = OVL_NEXT (fns))
{
tree fn = OVL_CURRENT (fns);
tmpl = DECL_TI_TEMPLATE (t);
gen_tmpl = most_general_template (tmpl);
argvec = tsubst (DECL_TI_ARGS (t), args, complain, in_decl);
+ if (argvec != error_mark_node)
+ argvec = (coerce_innermost_template_parms
+ (DECL_TEMPLATE_PARMS (gen_tmpl),
+ argvec, t, complain,
+ /*all*/true, /*defarg*/true));
if (argvec == error_mark_node)
RETURN (error_mark_node);
hash = hash_tmpl_and_args (gen_tmpl, argvec);
--- /dev/null
+// { dg-do compile { target c++14 } }
+
+using fl = float;
+
+template<class T> const int V = 0;
+template<> const int V<fl> = 42;
+
+static_assert(V<float> == 42, "");
--- /dev/null
+// { dg-do compile { target c++14 } }
+
+template <class T> const int V = 0;
+template <> const int V<char> = 42;
+
+template <class T>
+struct A
+{
+ using N = T;
+};
+
+#define SA(X) static_assert((X),#X)
+template <class T>
+struct B
+{
+ SA(V<typename A<T>::N> == 42);
+};
+
+B<char> b;