re PR c++/64898 (qtgui-4.8.6 build error)
authorJason Merrill <jason@redhat.com>
Thu, 12 Feb 2015 22:44:38 +0000 (17:44 -0500)
committerJason Merrill <jason@gcc.gnu.org>
Thu, 12 Feb 2015 22:44:38 +0000 (17:44 -0500)
PR c++/64898
* mangle.c (write_mangled_name): Fix test for variable template
instantiation.

From-SVN: r220666

gcc/cp/ChangeLog
gcc/cp/mangle.c
gcc/testsuite/g++.dg/abi/mangle65.C [new file with mode: 0644]

index 4f7564644e20076199a788adbb5b7ec57fa25c58..f181554219a5b7548189f9d5e7658c8d3255b5a9 100644 (file)
@@ -1,5 +1,9 @@
 2015-02-12  Jason Merrill  <jason@redhat.com>
 
+       PR c++/64898
+       * mangle.c (write_mangled_name): Fix test for variable template
+       instantiation.
+
        * decl.c (begin_destructor_body): Condition clobber on
        -flifetime-dse.
 
index 45377fc02e4a0036e7d216bd97e289695b2afcf2..fbf4bf27c077368c050f336cd8ccc538d694b8af 100644 (file)
@@ -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
diff --git a/gcc/testsuite/g++.dg/abi/mangle65.C b/gcc/testsuite/g++.dg/abi/mangle65.C
new file mode 100644 (file)
index 0000000..13169c2
--- /dev/null
@@ -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>();
+}