new file mode 100644
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+
+class C
+{
+ int y, x;
+ void i ();
+ bool __attribute__((const)) xx () { return x; }
+};
+
+void C::i ()
+{
+ if (xx ())
+ x = 1;
+}
@@ -5015,6 +5015,13 @@ ipa_sra_preliminary_function_checks (struct cgraph_node *node)
return false;
}
+ if (lookup_attribute ("const", DECL_ATTRIBUTES (node->decl)))
+ {
+ if (dump_file)
+ fprintf (dump_file, "Function has const attribute.\n");
+ return false;
+ }
+
if (!tree_versionable_function_p (node->decl))
{
if (dump_file)