aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/gimple.c3
-rw-r--r--gcc/testsuite/g++.dg/opt/pr98130.C25
2 files changed, 27 insertions, 1 deletions
diff --git a/gcc/gimple.c b/gcc/gimple.c
index e8246b7..bb13458 100644
--- a/gcc/gimple.c
+++ b/gcc/gimple.c
@@ -1514,11 +1514,12 @@ gimple_call_fnspec (const gcall *stmt)
such operator, then we can treat it as free. */
if (fndecl
&& DECL_IS_OPERATOR_DELETE_P (fndecl)
+ && DECL_IS_REPLACEABLE_OPERATOR (fndecl)
&& gimple_call_from_new_or_delete (stmt))
return ".co ";
/* Similarly operator new can be treated as malloc. */
if (fndecl
- && DECL_IS_OPERATOR_NEW_P (fndecl)
+ && DECL_IS_REPLACEABLE_OPERATOR_NEW_P (fndecl)
&& gimple_call_from_new_or_delete (stmt))
return "mC";
return "";
diff --git a/gcc/testsuite/g++.dg/opt/pr98130.C b/gcc/testsuite/g++.dg/opt/pr98130.C
new file mode 100644
index 0000000..0af55ef
--- /dev/null
+++ b/gcc/testsuite/g++.dg/opt/pr98130.C
@@ -0,0 +1,25 @@
+// PR c++/98130
+// { dg-do run { target c++11 } }
+// { dg-options "-O2" }
+
+#include <new>
+
+typedef int *T;
+
+static unsigned char storage[sizeof (T)] alignas (T);
+static T *p = (T *) storage;
+
+static inline __attribute__((__always_inline__)) void
+foo (T value)
+{
+ new (p) T(value);
+}
+
+int
+main ()
+{
+ int a;
+ foo (&a);
+ if (!*p)
+ __builtin_abort ();
+}