* decl.c (poplevel): Don't warn about unused vars in template scope.
* error.c (dump_decl): Handle variable templates.
From-SVN: r215472
+2014-09-22 Jason Merrill <jason@redhat.com>
+
+ * decl.c (poplevel): Don't warn about unused vars in template scope.
+ * error.c (dump_decl): Handle variable templates.
+
2014-09-20 Jason Merrill <jason@redhat.com>
PR c++/62017
/* Before we remove the declarations first check for unused variables. */
if ((warn_unused_variable || warn_unused_but_set_variable)
+ && current_binding_level->kind != sk_template_parms
&& !processing_template_decl)
for (tree d = getdecls (); d; d = TREE_CHAIN (d))
{
case FIELD_DECL:
case PARM_DECL:
dump_simple_decl (pp, t, TREE_TYPE (t), flags);
+
+ /* Handle variable template specializations. */
+ if (TREE_CODE (t) == VAR_DECL
+ && DECL_LANG_SPECIFIC (t)
+ && DECL_TEMPLATE_INFO (t)
+ && PRIMARY_TEMPLATE_P (DECL_TI_TEMPLATE (t)))
+ {
+ pp_cxx_begin_template_argument_list (pp);
+ tree args = INNERMOST_TEMPLATE_ARGS (DECL_TI_ARGS (t));
+ dump_template_argument_list (pp, args, flags);
+ pp_cxx_end_template_argument_list (pp);
+ }
break;
case RESULT_DECL:
--- /dev/null
+// { dg-do compile { target c++14 } }
+// { dg-options "-Wall" }
+
+template <class T> T x;
+template <> int x<int> = 0;
+
+int main()
+{
+ return x<int>;
+}
--- /dev/null
+// { dg-do compile { target c++14 } }
+
+template <class T> T x;
+template <> int x<int> = 0;
+template <> int x<int> = 0; // { dg-error "x<int>" }