aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp
diff options
context:
space:
mode:
authorPaolo Carlini <paolo.carlini@oracle.com>2019-11-15 22:56:33 +0000
committerPaolo Carlini <paolo@gcc.gnu.org>2019-11-15 22:56:33 +0000
commit2ab340fe17e7b5021c980badab9f5318d1517646 (patch)
tree5ddf11c67b73a26f5d9f6044364c25d305ebc795 /gcc/cp
parentf982d12a51cd91c7a16af22f8054bfb648fe54ca (diff)
downloadgcc-2ab340fe17e7b5021c980badab9f5318d1517646.zip
gcc-2ab340fe17e7b5021c980badab9f5318d1517646.tar.gz
gcc-2ab340fe17e7b5021c980badab9f5318d1517646.tar.bz2
typeck.c (cp_truthvalue_conversion): Add tsubst_flags_t parameter and use it in calls...
/cp 2019-11-15 Paolo Carlini <paolo.carlini@oracle.com> * typeck.c (cp_truthvalue_conversion): Add tsubst_flags_t parameter and use it in calls; also pass the location_t of the expression to cp_build_binary_op and c_common_truthvalue_conversion. * rtti.c (build_dynamic_cast_1): Adjust call. * cvt.c (ocp_convert): Likewise. * cp-gimplify.c (cp_fold): Likewise. * cp-tree.h (cp_truthvalue_conversion): Update declaration. /testsuite 2019-11-15 Paolo Carlini <paolo.carlini@oracle.com> * g++.dg/warn/Walways-true-1.C: Check locations too. * g++.dg/warn/Walways-true-2.C: Likewise. * g++.dg/warn/Walways-true-3.C: Likewise. * g++.dg/warn/Waddress-1.C: Check additional location. From-SVN: r278320
Diffstat (limited to 'gcc/cp')
-rw-r--r--gcc/cp/ChangeLog10
-rw-r--r--gcc/cp/cp-gimplify.c4
-rw-r--r--gcc/cp/cp-tree.h2
-rw-r--r--gcc/cp/cvt.c4
-rw-r--r--gcc/cp/rtti.c2
-rw-r--r--gcc/cp/typeck.c7
6 files changed, 20 insertions, 9 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 0129731..429ffd6 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,13 @@
+2019-11-15 Paolo Carlini <paolo.carlini@oracle.com>
+
+ * typeck.c (cp_truthvalue_conversion): Add tsubst_flags_t parameter
+ and use it in calls; also pass the location_t of the expression to
+ cp_build_binary_op and c_common_truthvalue_conversion.
+ * rtti.c (build_dynamic_cast_1): Adjust call.
+ * cvt.c (ocp_convert): Likewise.
+ * cp-gimplify.c (cp_fold): Likewise.
+ * cp-tree.h (cp_truthvalue_conversion): Update declaration.
+
2019-11-14 Jason Merrill <jason@redhat.com>
Implement P1816R0, class template argument deduction for aggregates.
diff --git a/gcc/cp/cp-gimplify.c b/gcc/cp/cp-gimplify.c
index 744707e..6076697 100644
--- a/gcc/cp/cp-gimplify.c
+++ b/gcc/cp/cp-gimplify.c
@@ -2573,9 +2573,9 @@ cp_fold (tree x)
{
warning_sentinel s (warn_int_in_bool_context);
if (!VOID_TYPE_P (TREE_TYPE (op1)))
- op1 = cp_truthvalue_conversion (op1);
+ op1 = cp_truthvalue_conversion (op1, tf_warning_or_error);
if (!VOID_TYPE_P (TREE_TYPE (op2)))
- op2 = cp_truthvalue_conversion (op2);
+ op2 = cp_truthvalue_conversion (op2, tf_warning_or_error);
}
else if (VOID_TYPE_P (TREE_TYPE (x)))
{
diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index 56b75ca..d6e9357 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -7450,7 +7450,7 @@ enum compare_bounds_t { bounds_none, bounds_either, bounds_first };
extern bool cxx_mark_addressable (tree, bool = false);
extern int string_conv_p (const_tree, const_tree, int);
-extern tree cp_truthvalue_conversion (tree);
+extern tree cp_truthvalue_conversion (tree, tsubst_flags_t);
extern tree contextual_conv_bool (tree, tsubst_flags_t);
extern tree condition_conversion (tree);
extern tree require_complete_type (tree);
diff --git a/gcc/cp/cvt.c b/gcc/cp/cvt.c
index 23facb7..bca687f 100644
--- a/gcc/cp/cvt.c
+++ b/gcc/cp/cvt.c
@@ -841,13 +841,13 @@ ocp_convert (tree type, tree expr, int convtype, int flags,
if (SCOPED_ENUM_P (intype) && (convtype & CONV_STATIC))
e = build_nop (ENUM_UNDERLYING_TYPE (intype), e);
if (complain & tf_warning)
- return cp_truthvalue_conversion (e);
+ return cp_truthvalue_conversion (e, complain);
else
{
/* Prevent bogus -Wint-in-bool-context warnings coming
from c_common_truthvalue_conversion down the line. */
warning_sentinel w (warn_int_in_bool_context);
- return cp_truthvalue_conversion (e);
+ return cp_truthvalue_conversion (e, complain);
}
}
diff --git a/gcc/cp/rtti.c b/gcc/cp/rtti.c
index 1ba4a46..d987f8b 100644
--- a/gcc/cp/rtti.c
+++ b/gcc/cp/rtti.c
@@ -782,7 +782,7 @@ build_dynamic_cast_1 (tree type, tree expr, tsubst_flags_t complain)
tree neq;
result = save_expr (result);
- neq = cp_truthvalue_conversion (result);
+ neq = cp_truthvalue_conversion (result, complain);
return cp_convert (type,
build3 (COND_EXPR, TREE_TYPE (result),
neq, result, bad), complain);
diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c
index 3144b7e..747ae42 100644
--- a/gcc/cp/typeck.c
+++ b/gcc/cp/typeck.c
@@ -5981,15 +5981,16 @@ cp_build_addressof (location_t loc, tree arg, tsubst_flags_t complain)
-1. */
tree
-cp_truthvalue_conversion (tree expr)
+cp_truthvalue_conversion (tree expr, tsubst_flags_t complain)
{
tree type = TREE_TYPE (expr);
+ location_t loc = cp_expr_loc_or_input_loc (expr);
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 (input_location, NE_EXPR, expr, nullptr_node, true);
+ return cp_build_binary_op (loc, NE_EXPR, expr, nullptr_node, complain);
else
- return c_common_truthvalue_conversion (input_location, expr);
+ return c_common_truthvalue_conversion (loc, expr);
}
/* Returns EXPR contextually converted to bool. */