aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2019-04-24 10:08:07 +0000
committerRichard Biener <rguenth@gcc.gnu.org>2019-04-24 10:08:07 +0000
commitbe39d6f0379ab74356cf406974055c3a1e68d127 (patch)
tree536b7efc8d081600600564418ea0eb476ce9f406
parentf9bfdfa2025512c8adb1e280e2df98e0512fbf30 (diff)
downloadgcc-be39d6f0379ab74356cf406974055c3a1e68d127.zip
gcc-be39d6f0379ab74356cf406974055c3a1e68d127.tar.gz
gcc-be39d6f0379ab74356cf406974055c3a1e68d127.tar.bz2
call.c (null_ptr_cst_p): Order checks according to expensiveness.
2019-04-24 Richard Biener <rguenther@suse.de> cp/ * call.c (null_ptr_cst_p): Order checks according to expensiveness. (conversion_null_warnings): Likewise. * typeck.c (same_type_ignoring_top_level_qualifiers_p): Return early if type1 == type2. From-SVN: r270539
-rw-r--r--gcc/cp/ChangeLog7
-rw-r--r--gcc/cp/call.c17
-rw-r--r--gcc/cp/typeck.c2
3 files changed, 18 insertions, 8 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index d207d95..3a6dc65 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,10 @@
+2019-04-24 Richard Biener <rguenther@suse.de>
+
+ * call.c (null_ptr_cst_p): Order checks according to expensiveness.
+ (conversion_null_warnings): Likewise.
+ * typeck.c (same_type_ignoring_top_level_qualifiers_p): Return
+ early if type1 == type2.
+
2019-04-22 Jason Merrill <jason@redhat.com>
PR c++/87366 - wrong error with alias template.
diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index f27a80d..23898f0 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -541,11 +541,11 @@ null_ptr_cst_p (tree t)
STRIP_ANY_LOCATION_WRAPPER (t);
/* Core issue 903 says only literal 0 is a null pointer constant. */
- if (TREE_CODE (type) == INTEGER_TYPE
- && !char_type_p (type)
- && TREE_CODE (t) == INTEGER_CST
+ if (TREE_CODE (t) == INTEGER_CST
+ && !TREE_OVERFLOW (t)
+ && TREE_CODE (type) == INTEGER_TYPE
&& integer_zerop (t)
- && !TREE_OVERFLOW (t))
+ && !char_type_p (type))
return true;
}
else if (CP_INTEGRAL_TYPE_P (type))
@@ -6858,8 +6858,9 @@ static void
conversion_null_warnings (tree totype, tree expr, tree fn, int argnum)
{
/* Issue warnings about peculiar, but valid, uses of NULL. */
- if (null_node_p (expr) && TREE_CODE (totype) != BOOLEAN_TYPE
- && ARITHMETIC_TYPE_P (totype))
+ if (TREE_CODE (totype) != BOOLEAN_TYPE
+ && ARITHMETIC_TYPE_P (totype)
+ && null_node_p (expr))
{
location_t loc = get_location_for_expr_unwinding_for_system_header (expr);
if (fn)
@@ -6896,8 +6897,8 @@ conversion_null_warnings (tree totype, tree expr, tree fn, int argnum)
}
/* Handle zero as null pointer warnings for cases other
than EQ_EXPR and NE_EXPR */
- else if (null_ptr_cst_p (expr) &&
- (TYPE_PTR_OR_PTRMEM_P (totype) || NULLPTR_TYPE_P (totype)))
+ else if ((TYPE_PTR_OR_PTRMEM_P (totype) || NULLPTR_TYPE_P (totype))
+ && null_ptr_cst_p (expr))
{
location_t loc = get_location_for_expr_unwinding_for_system_header (expr);
maybe_warn_zero_as_null_pointer_constant (expr, loc);
diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c
index fff88ab8..c107a32 100644
--- a/gcc/cp/typeck.c
+++ b/gcc/cp/typeck.c
@@ -1523,6 +1523,8 @@ same_type_ignoring_top_level_qualifiers_p (tree type1, tree type2)
{
if (type1 == error_mark_node || type2 == error_mark_node)
return false;
+ if (type1 == type2)
+ return true;
type1 = cp_build_qualified_type (type1, TYPE_UNQUALIFIED);
type2 = cp_build_qualified_type (type2, TYPE_UNQUALIFIED);