Commit 8bee092e by Jakub Jelinek

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
parent 4d1b8e70
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>
......
......@@ -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)
{
......
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.
......
// { 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>
......
// { 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>
......
// { 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>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment