Commit ead51d36 by Jakub Jelinek Committed by Jakub Jelinek

re PR c/35430 (ICE with complex arithmetic)

	PR c/35430
	* c-common.c (warn_for_sign_compare): For complex result_type
	use component's type.

	* gcc.dg/pr35430.c: New test.
	* g++.dg/warn/Wsign-compare-2.C: New test.

Co-Authored-By: Andrew Pinski <andrew_pinski@playstation.sony.com>

From-SVN: r141587
parent d2bd0052
2008-11-04 Jakub Jelinek <jakub@redhat.com>
Andrew Pinski <andrew_pinski@playstation.sony.com>
PR c/35430
* c-common.c (warn_for_sign_compare): For complex result_type
use component's type.
2008-11-04 Jakub Jelinek <jakuB@redhat.com>
* print-tree.c (print_node): Use code instead of TREE_CODE (node).
......
......@@ -8258,7 +8258,7 @@ warn_for_sign_compare (location_t location,
/* OK */;
else
{
tree sop, uop;
tree sop, uop, base_type;
bool ovf;
if (op0_signed)
......@@ -8268,6 +8268,8 @@ warn_for_sign_compare (location_t location,
STRIP_TYPE_NOPS (sop);
STRIP_TYPE_NOPS (uop);
base_type = (TREE_CODE (result_type) == COMPLEX_TYPE
? TREE_TYPE (result_type) : result_type);
/* Do not warn if the signed quantity is an unsuffixed integer
literal (or some static constant expression involving such
......@@ -8280,7 +8282,7 @@ warn_for_sign_compare (location_t location,
in the result if the result were signed. */
else if (TREE_CODE (uop) == INTEGER_CST
&& (resultcode == EQ_EXPR || resultcode == NE_EXPR)
&& int_fits_type_p (uop, c_common_signed_type (result_type)))
&& int_fits_type_p (uop, c_common_signed_type (base_type)))
/* OK */;
/* In C, do not warn if the unsigned quantity is an enumeration
constant and its maximum value would fit in the result if the
......@@ -8288,7 +8290,7 @@ warn_for_sign_compare (location_t location,
else if (!c_dialect_cxx() && TREE_CODE (uop) == INTEGER_CST
&& TREE_CODE (TREE_TYPE (uop)) == ENUMERAL_TYPE
&& int_fits_type_p (TYPE_MAX_VALUE (TREE_TYPE (uop)),
c_common_signed_type (result_type)))
c_common_signed_type (base_type)))
/* OK */;
else
warning_at (location,
......
2008-11-04 Jakub Jelinek <jakub@redhat.com>
Andrew Pinski <andrew_pinski@playstation.sony.com>
PR c/35430
* gcc.dg/pr35430.c: New test.
* g++.dg/warn/Wsign-compare-2.C: New test.
2008-11-04 Jakub Jelinek <jakub@redhat.com>
PR c/37106
* gcc.dg/pr37106-1.c: New test.
......
// PR c/35430
// { dg-do compile }
// { dg-options "-Wsign-compare" }
void
foo (__complex__ int i)
{
i == 0u;
i == ~1u; // { dg-warning "comparison between signed and unsigned integer expressions" }
}
/* PR c/35430 */
/* { dg-do compile } */
/* { dg-options "-Wsign-compare" } */
void
foo (__complex__ int i)
{
i == 0u;
i == ~1u; /* { dg-warning "comparison between signed and unsigned integer expressions" } */
}
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