OSDN Git Service

PR c++/47303
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 19 Jan 2011 15:36:57 +0000 (15:36 +0000)
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 19 Jan 2011 15:36:57 +0000 (15:36 +0000)
* decl2.c (finish_anon_union): Only call mangle_decl if TREE_STATIC
or DECL_EXTERNAL.

* g++.dg/template/anonunion1.C: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@169000 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/cp/ChangeLog
gcc/cp/decl2.c
gcc/cp/pt.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/template/anonunion1.C [new file with mode: 0644]

index 2491047..a28d672 100644 (file)
@@ -1,3 +1,9 @@
+2011-01-19  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/47303
+       * decl2.c (finish_anon_union): Only call mangle_decl if TREE_STATIC
+       or DECL_EXTERNAL.
+
 2011-01-17  Jason Merrill  <jason@redhat.com>
 
        PR c++/47067
index 72570c3..2885528 100644 (file)
@@ -1409,7 +1409,8 @@ finish_anon_union (tree anon_union_decl)
       /* Use main_decl to set the mangled name.  */
       DECL_NAME (anon_union_decl) = DECL_NAME (main_decl);
       maybe_commonize_var (anon_union_decl);
-      mangle_decl (anon_union_decl);
+      if (TREE_STATIC (anon_union_decl) || DECL_EXTERNAL (anon_union_decl))
+       mangle_decl (anon_union_decl);
       DECL_NAME (anon_union_decl) = NULL_TREE;
     }
 
index 16bd2a0..01f8cd7 100644 (file)
@@ -1,6 +1,6 @@
 /* Handle parameterized types (templates) for GNU C++.
    Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
-   2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010
+   2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010, 2011
    Free Software Foundation, Inc.
    Written by Ken Raeburn (raeburn@cygnus.com) while at Watchmaker Computing.
    Rewritten by Jason Merrill (jason@cygnus.com).
index ef62c3c..0962b70 100644 (file)
@@ -1,5 +1,8 @@
 2011-01-19  Jakub Jelinek  <jakub@redhat.com>
 
+       PR c++/47303
+       * g++.dg/template/anonunion1.C: New test.
+
        PR rtl-optimization/47337
        * gcc.c-torture/execute/pr47337.c: New test.
 
diff --git a/gcc/testsuite/g++.dg/template/anonunion1.C b/gcc/testsuite/g++.dg/template/anonunion1.C
new file mode 100644 (file)
index 0000000..89a8c5b
--- /dev/null
@@ -0,0 +1,24 @@
+// PR c++/47303
+// { dg-do compile }
+// { dg-options "-fabi-version=1" }
+
+struct Z
+{
+  void foo (int);
+};
+
+struct F
+{
+  typedef void (Z::*zm) (int);
+  typedef void (F::*fm) (int);
+  template <zm>
+  void bar (int)
+  {
+    union
+    {
+      Z z;
+    };
+  }
+};
+
+F::fm m = &F::bar <&Z::foo>;