aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorVille Voutilainen <ville.voutilainen@gmail.com>2017-11-13 19:02:06 +0200
committerVille Voutilainen <ville@gcc.gnu.org>2017-11-13 19:02:06 +0200
commit8f2b097ed54816d28cd51254c8e4616404ae348e (patch)
treeda7596f768a618dc8ddfbf2e19b6126dcb440a16 /gcc
parent81766d13a8e51e7432e2c1ff3fd1ef4735e3b820 (diff)
downloadgcc-8f2b097ed54816d28cd51254c8e4616404ae348e.zip
gcc-8f2b097ed54816d28cd51254c8e4616404ae348e.tar.gz
gcc-8f2b097ed54816d28cd51254c8e4616404ae348e.tar.bz2
Remove the null check from placement new in all modes
gcc/cp/ Remove the null check from placement new in all modes * init.c (build_new_1): Don't do a null check for a namespace-scope non-replaceable placement new in any mode unless -fcheck-new is provided. testsuite/ Remove the null check from placement new in all modes * g++.dg/init/pr35878_1.C: Adjust. * g++.dg/init/pr35878_4.C: New. * g++.dg/torture/pr48695.C: Adjust. * g++.dg/tree-ssa/pr31146-2.C: Likewise. * g++.dg/tree-ssa/pr41428.C: Adjust. From-SVN: r254694
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog7
-rw-r--r--gcc/cp/init.c2
-rw-r--r--gcc/testsuite/g++.dg/init/pr35878_1.C2
-rw-r--r--gcc/testsuite/g++.dg/init/pr35878_4.C23
-rw-r--r--gcc/testsuite/g++.dg/torture/pr48695.C1
-rw-r--r--gcc/testsuite/g++.dg/tree-ssa/pr31146-2.C7
-rw-r--r--gcc/testsuite/g++.dg/tree-ssa/pr41428.C7
7 files changed, 39 insertions, 10 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index df912013..73fa999 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,10 @@
+2017-11-13 Ville Voutilainen <ville.voutilainen@gmail.com>
+
+ Remove the null check from placement new in all modes
+ * init.c (build_new_1): Don't do a null check for
+ a namespace-scope non-replaceable placement new
+ in any mode unless -fcheck-new is provided.
+
2017-11-07 Boris Kolpackov <boris@codesynthesis.com>
* Make-lang.in (CP_PLUGIN_HEADERS): Add operators.def since included
diff --git a/gcc/cp/init.c b/gcc/cp/init.c
index 9e6e3af..1fcd91d 100644
--- a/gcc/cp/init.c
+++ b/gcc/cp/init.c
@@ -2758,7 +2758,7 @@ malloc_alignment ()
static bool
std_placement_new_fn_p (tree alloc_fn)
{
- if ((cxx_dialect > cxx14) && DECL_NAMESPACE_SCOPE_P (alloc_fn))
+ if (DECL_NAMESPACE_SCOPE_P (alloc_fn))
{
tree first_arg = TREE_CHAIN (TYPE_ARG_TYPES (TREE_TYPE (alloc_fn)));
if ((TREE_VALUE (first_arg) == ptr_type_node)
diff --git a/gcc/testsuite/g++.dg/init/pr35878_1.C b/gcc/testsuite/g++.dg/init/pr35878_1.C
index e2fc493..7fb3221 100644
--- a/gcc/testsuite/g++.dg/init/pr35878_1.C
+++ b/gcc/testsuite/g++.dg/init/pr35878_1.C
@@ -1,7 +1,7 @@
// PR c++/35878
// { dg-do compile }
// { dg-options "-O2 -std=gnu++11 -fdump-tree-optimized" }
-// { dg-final { scan-tree-dump-times "v_\[0-9]+\\(D\\) \[=!]= 0" 1 "optimized" } }
+// { dg-final { scan-tree-dump-not "v_\[0-9]+\\(D\\) \[=!]= 0" "optimized" } }
#include <new>
#include <utility>
diff --git a/gcc/testsuite/g++.dg/init/pr35878_4.C b/gcc/testsuite/g++.dg/init/pr35878_4.C
new file mode 100644
index 0000000..bd27565
--- /dev/null
+++ b/gcc/testsuite/g++.dg/init/pr35878_4.C
@@ -0,0 +1,23 @@
+// PR c++/35878
+// { dg-do compile }
+// { dg-options "-O2 -std=gnu++11 -fcheck-new -fdump-tree-optimized" }
+// { dg-final { scan-tree-dump-times "v_\[0-9]+\\(D\\) \[=!]= 0" 1 "optimized" } }
+
+#include <new>
+#include <utility>
+
+struct s1{
+ int a;
+ int b;
+ int c;
+};
+
+void f1 (s1 * v, s1&& s)
+{
+ new (v) s1(std::move(s));
+}
+
+void f2 (s1 * v, s1&& s)
+{
+ *v = std::move(s);
+}
diff --git a/gcc/testsuite/g++.dg/torture/pr48695.C b/gcc/testsuite/g++.dg/torture/pr48695.C
index 44e6c77..2f2953d 100644
--- a/gcc/testsuite/g++.dg/torture/pr48695.C
+++ b/gcc/testsuite/g++.dg/torture/pr48695.C
@@ -1,4 +1,5 @@
// { dg-do run }
+/* { dg-options "-fcheck-new" } */
typedef __SIZE_TYPE__ size_t;
diff --git a/gcc/testsuite/g++.dg/tree-ssa/pr31146-2.C b/gcc/testsuite/g++.dg/tree-ssa/pr31146-2.C
index 500d8b6..9fb5dc1 100644
--- a/gcc/testsuite/g++.dg/tree-ssa/pr31146-2.C
+++ b/gcc/testsuite/g++.dg/tree-ssa/pr31146-2.C
@@ -1,5 +1,5 @@
/* { dg-do compile } */
-/* { dg-options "-O -fno-tree-vrp -fdump-tree-forwprop1" } */
+/* { dg-options "-O -fcheck-new -fno-tree-vrp -fdump-tree-forwprop1" } */
#include <new>
@@ -20,6 +20,5 @@ double foo (void)
return v.a[2];
}
-/* -std=c++17 and above doesn't emit operator new () != NULL, so there is
- nothing to fold anymore. */
-/* { dg-final { scan-tree-dump "Replaced .* != 0B. with .1" "forwprop1" { target c++14_down } } } */
+/* GCC 8 emits operator new () != NULL with -fcheck-new. */
+/* { dg-final { scan-tree-dump "Replaced .* != 0B. with .1" "forwprop1" } } */
diff --git a/gcc/testsuite/g++.dg/tree-ssa/pr41428.C b/gcc/testsuite/g++.dg/tree-ssa/pr41428.C
index c0a5eb6..7aff519 100644
--- a/gcc/testsuite/g++.dg/tree-ssa/pr41428.C
+++ b/gcc/testsuite/g++.dg/tree-ssa/pr41428.C
@@ -1,5 +1,5 @@
/* { dg-do compile } */
-/* { dg-options "-O -fdump-tree-ccp1-details" } */
+/* { dg-options "-O -fcheck-new -fdump-tree-ccp1-details" } */
extern "C" void abort (void);
inline void *operator new (__SIZE_TYPE__, void *__p) throw () { return __p; }
@@ -11,6 +11,5 @@ int foo(void)
return *(int *)&f;
}
-/* -std=c++17 and above doesn't emit operator new () != NULL, so there is
- nothing to fold anymore. */
-/* { dg-final { scan-tree-dump "Folded into: if \\\(1 != 0\\\)" "ccp1" { target c++14_down } } } */
+/* GCC 8 emits operator new () != NULL with -fcheck-new. */
+/* { dg-final { scan-tree-dump "Folded into: if \\\(1 != 0\\\)" "ccp1" } } */