commit 6f16507d6457d8a43fda62f1f78e9d2e3557f3de
Author: Jason Merrill <jason@redhat.com>
Date: Thu Feb 12 16:50:11 2015 -0500
PR c++/64898
* mangle.c (write_mangled_name): Fix test for variable template
instantiation.
@@ -682,7 +682,8 @@ write_mangled_name (const tree decl, bool top_level)
}
else if (VAR_P (decl)
/* Variable template instantiations are mangled. */
- && !(DECL_LANG_SPECIFIC (decl) && DECL_TEMPLATE_INFO (decl))
+ && !(DECL_LANG_SPECIFIC (decl) && DECL_TEMPLATE_INFO (decl)
+ && variable_template_p (DECL_TI_TEMPLATE (decl)))
/* The names of non-static global variables aren't mangled. */
&& DECL_EXTERNAL_LINKAGE_P (decl)
&& (CP_DECL_CONTEXT (decl) == global_namespace
new file mode 100644
@@ -0,0 +1,13 @@
+// PR c++/64898
+// { dg-final { scan-assembler-not "_Z6foovar" } }
+
+template <class> void f()
+{
+ extern int foovar;
+ foovar = 42;
+}
+
+int main()
+{
+ f<int>();
+}