diff options
author | paolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-11-01 23:28:19 +0000 |
---|---|---|
committer | paolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-11-01 23:28:19 +0000 |
commit | 8fe701f5543e807309b540a942a98579550d9091 (patch) | |
tree | fa8cf61a13cc6e8d63e6a7ada7b5a330722a63fc /gcc/cp/init.c | |
parent | d3f277f44d20538b002988754e9a453bd3485ebe (diff) | |
download | gcc-8fe701f5543e807309b540a942a98579550d9091.tar.gz |
/cp
2011-11-01 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/44277
* cvt.c (cp_convert_to_pointer): Warn for zero as null pointer
constant.
* typeck.c (cp_truthvalue_conversion): Handle pointers and member
function pointers under c_inhibit_evaluation_warnings; use
nullptr_node for data member pointers.
(cp_build_binary_op): Tweak, just forward to cp_convert op1,
either a nullptr_node or an integer_zero_node.
(build_ptrmemfunc): Use nullptr_node.
* init.c (build_zero_init_1): Likewise.
/c-family
2011-11-01 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/44277
* c.opt: Add Wzero-as-null-pointer-constant.
/gcc
2011-11-01 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/44277
* doc/invoke.texi: Document -Wzero-as-null-pointer-constant.
/testsuite
2011-11-01 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/44277
* g++.dg/warn/Wzero-as-null-pointer-constant-1.C: New.
* g++.dg/cpp0x/Wzero-as-null-pointer-constant-1.C: Likewise.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@180750 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cp/init.c')
-rw-r--r-- | gcc/cp/init.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/gcc/cp/init.c b/gcc/cp/init.c index 9115df3dba6..6b57eb60a65 100644 --- a/gcc/cp/init.c +++ b/gcc/cp/init.c @@ -176,6 +176,8 @@ build_zero_init_1 (tree type, tree nelts, bool static_storage_p, items with static storage duration that are not otherwise initialized are initialized to zero. */ ; + else if (TYPE_PTR_P (type) || TYPE_PTR_TO_MEMBER_P (type)) + init = convert (type, nullptr_node); else if (SCALAR_TYPE_P (type)) init = convert (type, integer_zero_node); else if (CLASS_TYPE_P (type)) |