Hi!

The recently added assert in mangle.c doesn't like mangling to be performed
during processing_template_decl.  With #pragma weak foo we can hit it
unfortunately.  This patch fixes that.  Perhaps we could call
maybe_apply_pragma_weak from pt.c when instantiating, though not sure
how much useful will that be, aren't most templates weak already anyway?

Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

2012-03-29  Jakub Jelinek  <ja...@redhat.com>

        PR c++/52759
        * decl.c (start_decl): Don't call maybe_apply_pragma_weak
        if processing_template_decl.

        * g++.dg/ext/weak4.C: New test.

--- gcc/cp/decl.c.jj    2012-03-26 11:53:18.000000000 +0200
+++ gcc/cp/decl.c       2012-03-29 10:17:22.392169256 +0200
@@ -4431,7 +4431,8 @@ start_decl (const cp_declarator *declara
     }
 
   /* If #pragma weak was used, mark the decl weak now.  */
-  maybe_apply_pragma_weak (decl);
+  if (!processing_template_decl)
+    maybe_apply_pragma_weak (decl);
 
   if (TREE_CODE (decl) == FUNCTION_DECL
       && DECL_DECLARED_INLINE_P (decl)
--- gcc/testsuite/g++.dg/ext/weak4.C.jj 2012-03-29 10:23:00.506445582 +0200
+++ gcc/testsuite/g++.dg/ext/weak4.C    2012-03-29 10:22:00.000000000 +0200
@@ -0,0 +1,9 @@
+// PR c++/52759
+// { dg-do compile }
+// { dg-require-weak "" }
+// { dg-options "" }
+#pragma weak foo
+template <typename T>
+struct A { };
+template <typename T>
+void bar (A<T> &);

        Jakub

Reply via email to