@@ -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;
}
@@ -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>;