From 8bee092e7f9bfceae0076ebd5b7260b8b07aaf5c Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Tue, 21 Mar 2017 08:30:48 +0100 Subject: [PATCH] re PR c++/35878 ([LWG 2302] Useless NULL pointer check when constructing object) 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 | 7 ++++++- gcc/cp/init.c | 7 ++++--- gcc/testsuite/ChangeLog | 8 ++++++++ gcc/testsuite/g++.dg/init/pr35878_1.C | 6 ++++-- gcc/testsuite/g++.dg/init/pr35878_2.C | 6 ++++-- gcc/testsuite/g++.dg/init/pr35878_3.C | 6 ++++-- 6 files changed, 30 insertions(+), 10 deletions(-) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 8264502e050..00dd769edd7 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,7 +1,12 @@ +2017-03-21 Jakub Jelinek + + PR c++/35878 + * init.c (std_placement_new_fn_p, build_new_1): Formatting fixes. + 2017-03-21 Ville Voutilainen 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 diff --git a/gcc/cp/init.c b/gcc/cp/init.c index 4ec26afa235..773279504ee 100644 --- a/gcc/cp/init.c +++ b/gcc/cp/init.c @@ -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 **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) { diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 79672408fe2..c2dc55a42ef 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,11 @@ +2017-03-21 Jakub Jelinek + + 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 PR c/80097 diff --git a/gcc/testsuite/g++.dg/init/pr35878_1.C b/gcc/testsuite/g++.dg/init/pr35878_1.C index b45c0097a93..e2fc4933425 100644 --- a/gcc/testsuite/g++.dg/init/pr35878_1.C +++ b/gcc/testsuite/g++.dg/init/pr35878_1.C @@ -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 #include diff --git a/gcc/testsuite/g++.dg/init/pr35878_2.C b/gcc/testsuite/g++.dg/init/pr35878_2.C index 066449419b9..c675cb6ed64 100644 --- a/gcc/testsuite/g++.dg/init/pr35878_2.C +++ b/gcc/testsuite/g++.dg/init/pr35878_2.C @@ -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 #include diff --git a/gcc/testsuite/g++.dg/init/pr35878_3.C b/gcc/testsuite/g++.dg/init/pr35878_3.C index 8a5614f12ff..9317ea1b231 100644 --- a/gcc/testsuite/g++.dg/init/pr35878_3.C +++ b/gcc/testsuite/g++.dg/init/pr35878_3.C @@ -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 #include -- 2.30.2