commit f7142c9ff05259adbda2cb5797088b6a2c281ad9
Author: Jason Merrill <jason@redhat.com>
Date: Wed Jan 9 11:44:13 2013 -0500
PR c++/55893
* decl.c (cp_finish_decl): Clear TREE_READONLY if the variable
needs destruction.
@@ -6417,6 +6417,10 @@ cp_finish_decl (tree decl, tree init, bool init_const_expr_p,
}
else if (was_readonly)
TREE_READONLY (decl) = 1;
+
+ /* Likewise if it needs destruction. */
+ if (TYPE_HAS_NONTRIVIAL_DESTRUCTOR (type))
+ TREE_READONLY (decl) = 0;
}
make_rtl_for_nonlocal_decl (decl, init, asmspec);
new file mode 100644
@@ -0,0 +1,12 @@
+// PR c++/55893
+// { dg-final { scan-assembler-not "rodata" } }
+
+struct foo
+{
+ virtual ~foo ();
+};
+
+int main ()
+{
+ static const foo tmp;
+}