diff options
author | Jason Merrill <jason@redhat.com> | 2016-07-21 02:05:39 -0400 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2016-07-21 02:05:39 -0400 |
commit | 451dcc6693e5e489f9f5bf6ba90cedf8f335ad00 (patch) | |
tree | ad779ad8440332e26e9a3100fdf1370031d7ddd3 /gcc/cp | |
parent | e96fe88c518ddc2d8917355d1781de3f8714c348 (diff) | |
download | gcc-451dcc6693e5e489f9f5bf6ba90cedf8f335ad00.zip gcc-451dcc6693e5e489f9f5bf6ba90cedf8f335ad00.tar.gz gcc-451dcc6693e5e489f9f5bf6ba90cedf8f335ad00.tar.bz2 |
PR c++/65168 - -Waddress in unevaluated context.
gcc/c-family/
* c-common.c (c_common_truthvalue_conversion): Check
c_inhibit_evaluation_warnings for warning about address of
reference.
gcc/cp/
* typeck.c (cp_truthvalue_conversion): Compare pointers to nullptr.
Don't set c_inhibit_evaluation_warnings.
From-SVN: r238560
Diffstat (limited to 'gcc/cp')
-rw-r--r-- | gcc/cp/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/cp/typeck.c | 15 |
2 files changed, 6 insertions, 13 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 8ff7f75..be223f2 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,9 @@ 2016-07-21 Jason Merrill <jason@redhat.com> + PR c++/65168 + * typeck.c (cp_truthvalue_conversion): Compare pointers to nullptr. + Don't set c_inhibit_evaluation_warnings. + PR c++/71121 * cp-gimplify.c (cp_fully_fold): First call maybe_constant_value. diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index f9e45ee..d4bfb11 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -5459,21 +5459,10 @@ tree cp_truthvalue_conversion (tree expr) { tree type = TREE_TYPE (expr); - if (TYPE_PTRDATAMEM_P (type) + if (TYPE_PTR_OR_PTRMEM_P (type) /* Avoid ICE on invalid use of non-static member function. */ || TREE_CODE (expr) == FUNCTION_DECL) - return build_binary_op (EXPR_LOCATION (expr), - NE_EXPR, expr, nullptr_node, 1); - else if (TYPE_PTR_P (type) || TYPE_PTRMEMFUNC_P (type)) - { - /* With -Wzero-as-null-pointer-constant do not warn for an - 'if (p)' or a 'while (!p)', where p is a pointer. */ - tree ret; - ++c_inhibit_evaluation_warnings; - ret = c_common_truthvalue_conversion (input_location, expr); - --c_inhibit_evaluation_warnings; - return ret; - } + return build_binary_op (input_location, NE_EXPR, expr, nullptr_node, 1); else return c_common_truthvalue_conversion (input_location, expr); } |