re PR c++/35878 ([LWG 2302] Useless NULL pointer check when constructing object)
authorJakub Jelinek <jakub@gcc.gnu.org>
Tue, 21 Mar 2017 07:30:48 +0000 (08:30 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Tue, 21 Mar 2017 07:30:48 +0000 (08:30 +0100)
PR c++/35878
* init.c (std_placement_new_fn_p, build_new_1): Formatting fixes.

* g++.dg/init/pr35878_1.C: Rewrite directives to scan optimized
dump instead of assembler.
* g++.dg/init/pr35878_2.C: Likewise.
* g++.dg/init/pr35878_3.C: Likewise.

From-SVN: r246303

gcc/cp/ChangeLog
gcc/cp/init.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/init/pr35878_1.C
gcc/testsuite/g++.dg/init/pr35878_2.C
gcc/testsuite/g++.dg/init/pr35878_3.C

index 8264502..00dd769 100644 (file)
@@ -1,7 +1,12 @@
+2017-03-21  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/35878
+       * init.c (std_placement_new_fn_p, build_new_1): Formatting fixes.
+
 2017-03-21  Ville Voutilainen  <ville.voutilainen@gmail.com>
 
        PR c++/35878
-       * cp/init.c (std_placement_new_fn_p): New.
+       * init.c (std_placement_new_fn_p): New.
        (build_new_1): Call it.
 
 2017-03-20  Jason Merrill  <jason@redhat.com>
index 4ec26af..7732795 100644 (file)
@@ -2710,7 +2710,8 @@ malloc_alignment ()
 /* Determine whether an allocation function is a namespace-scope
    non-replaceable placement new function. See DR 1748.
    TODO: Enable in all standard modes.  */
-static bool std_placement_new_fn_p (tree alloc_fn)
+static bool
+std_placement_new_fn_p (tree alloc_fn)
 {
   if ((cxx_dialect > cxx14) && DECL_NAMESPACE_SCOPE_P (alloc_fn))
     {
@@ -3200,8 +3201,8 @@ build_new_1 (vec<tree, va_gc> **placement, tree type, tree nelts,
      So check for a null exception spec on the op new we just called.  */
 
   nothrow = TYPE_NOTHROW_P (TREE_TYPE (alloc_fn));
-  check_new = flag_check_new
-    || (nothrow && !std_placement_new_fn_p (alloc_fn));
+  check_new
+    = flag_check_new || (nothrow && !std_placement_new_fn_p (alloc_fn));
 
   if (cookie_size)
     {
index 7967240..c2dc55a 100644 (file)
@@ -1,5 +1,13 @@
 2017-03-21  Jakub Jelinek  <jakub@redhat.com>
 
+       PR c++/35878
+       * g++.dg/init/pr35878_1.C: Rewrite directives to scan optimized
+       dump instead of assembler.
+       * g++.dg/init/pr35878_2.C: Likewise.
+       * g++.dg/init/pr35878_3.C: Likewise.
+
+2017-03-21  Jakub Jelinek  <jakub@redhat.com>
+
        PR c/80097
        * gcc.dg/ubsan/pr80097.c: New test.
 
index b45c009..e2fc493 100644 (file)
@@ -1,6 +1,8 @@
-// { dg-options "-O2 --std=gnu++11" }
+// PR c++/35878
 // { dg-do compile }
-// { dg-final { scan-assembler "test.*%rdi, %rdi" { target i?86-*-* x86_64-*-* } } }
+// { dg-options "-O2 -std=gnu++11 -fdump-tree-optimized" }
+// { dg-final { scan-tree-dump-times "v_\[0-9]+\\(D\\) \[=!]= 0" 1 "optimized" } }
+
 #include <new>
 #include <utility>
 
index 0664494..c675cb6 100644 (file)
@@ -1,6 +1,8 @@
-// { dg-options "-O2 --std=gnu++17 -fcheck-new" }
+// PR c++/35878
 // { dg-do compile }
-// { dg-final { scan-assembler "test.*%rdi, %rdi" { target i?86-*-* x86_64-*-* } } }
+// { dg-options "-O2 -std=gnu++17 -fcheck-new -fdump-tree-optimized" }
+// { dg-final { scan-tree-dump-times "v_\[0-9]+\\(D\\) \[=!]= 0" 1 "optimized" } }
+
 #include <new>
 #include <utility>
 
index 8a5614f..9317ea1 100644 (file)
@@ -1,6 +1,8 @@
-// { dg-options "-O2 --std=gnu++17" }
+// PR c++/35878
 // { dg-do compile }
-// { dg-final { scan-assembler-not "test.*%rdi, %rdi" { target i?86-*-* x86_64-*-* } } }
+// { dg-options "-O2 -std=gnu++17 -fdump-tree-optimized" }
+// { dg-final { scan-tree-dump-not "v_\[0-9]+\\(D\\) \[=!]= 0" "optimized" } }
+
 #include <new>
 #include <utility>