From: Marek Polacek Date: Fri, 2 Mar 2018 17:51:24 +0000 (+0000) Subject: re PR c++/84171 (ICE with -Wsign-compare) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=0805d020d789e40557531df22565eae7809e7f17;p=gcc.git re PR c++/84171 (ICE with -Wsign-compare) PR c++/84171 * c-warn.c (warn_for_sign_compare): Bail out if any of the operands is erroneous. * g++.dg/warn/Wsign-compare-8.C: New test. From-SVN: r258147 --- diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index 27cc43ee3a6..fe1fc81139e 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,9 @@ +2018-03-02 Marek Polacek + + PR c++/84171 + * c-warn.c (warn_for_sign_compare): Bail out if any of the operands + is erroneous. + 2018-03-02 Thomas Schwinge * c-attribs.c (c_common_attribute_table): Remove "cilk simd diff --git a/gcc/c-family/c-warn.c b/gcc/c-family/c-warn.c index f3fb62c7e62..7c385959c4f 100644 --- a/gcc/c-family/c-warn.c +++ b/gcc/c-family/c-warn.c @@ -1931,6 +1931,9 @@ warn_for_sign_compare (location_t location, tree op0, tree op1, tree result_type, enum tree_code resultcode) { + if (error_operand_p (orig_op0) || error_operand_p (orig_op1)) + return; + int op0_signed = !TYPE_UNSIGNED (TREE_TYPE (orig_op0)); int op1_signed = !TYPE_UNSIGNED (TREE_TYPE (orig_op1)); int unsignedp0, unsignedp1; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 0c73e80a6ff..a848cd3f2da 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-03-02 Marek Polacek + + PR c++/84171 + * g++.dg/warn/Wsign-compare-8.C: New test. + 2018-03-02 Jakub Jelinek PR c++/84662 diff --git a/gcc/testsuite/g++.dg/warn/Wsign-compare-8.C b/gcc/testsuite/g++.dg/warn/Wsign-compare-8.C new file mode 100644 index 00000000000..237ba84d526 --- /dev/null +++ b/gcc/testsuite/g++.dg/warn/Wsign-compare-8.C @@ -0,0 +1,8 @@ +// PR c++/84171 +// { dg-options "-Wsign-compare" } + +bool foo (char c) +{ + const int i = 0 = 0; // { dg-error "lvalue" } + return c = i; +} // { dg-warning "control reaches" }