Index: testsuite/g++.dg/tm/pr51411.C
===================================================================
--- testsuite/g++.dg/tm/pr51411.C	(revision 0)
+++ testsuite/g++.dg/tm/pr51411.C	(revision 0)
@@ -0,0 +1,7 @@
+// { dg-do compile }
+// { dg-options "-fgnu-tm -O" }
+
+struct A
+{
+  __attribute__ ((transaction_safe)) virtual void virtfoo () { }
+};
Index: trans-mem.c
===================================================================
--- trans-mem.c	(revision 182290)
+++ trans-mem.c	(working copy)
@@ -4256,10 +4256,7 @@ ipa_tm_create_version (struct cgraph_nod
       /* Remap extern inline to static inline.  */
       /* ??? Is it worth trying to use make_decl_one_only?  */
       if (DECL_DECLARED_INLINE_P (new_decl) && DECL_EXTERNAL (new_decl))
-	{
-	  DECL_EXTERNAL (new_decl) = 0;
-	  TREE_PUBLIC (new_decl) = 0;
-	}
+	TREE_PUBLIC (new_decl) = 0;
 
       tree_function_versioning (old_decl, new_decl, NULL, false, NULL,
 				NULL, NULL);
