diff options
author | Joseph Myers <joseph@codesourcery.com> | 2016-06-20 22:58:20 +0000 |
---|---|---|
committer | Joseph Myers <joseph@codesourcery.com> | 2016-06-20 22:58:20 +0000 |
commit | ae55140793b557b4cdef93866e6ab388816b3e4f (patch) | |
tree | 77aba49c84485917b8be4c68189cb2c5e87af15d | |
parent | ecd6db183e827cc092a08c2926b8382c39a12f08 (diff) |
Fix ICE on conditional expression between DFP and non-DFP float (PR c/71601).
A conditional expression between DFP and non-DFP floating-point
produces an ICE. This patch fixes this by making
build_conditional_expr return early when c_common_type produces an
error.
Bootstrapped with no regressions on x86_64-pc-linux-gnu.
PR c/71601
gcc/c:
* c-typeck.c (build_conditional_expr): Return error_mark_node if
c_common_type returns error_mark_node.
gcc/testsuite:
* gcc.dg/dfp/usual-arith-conv-bad-3.c: New test.
git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@237622 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r-- | gcc/c/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/c/c-typeck.c | 2 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/dfp/usual-arith-conv-bad-3.c | 13 |
4 files changed, 26 insertions, 0 deletions
diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index bd25ecaec6a..35b3de4a365 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,3 +1,9 @@ +2016-06-20 Joseph Myers <joseph@codesourcery.com> + + PR c/71601 + * c-typeck.c (build_conditional_expr): Return error_mark_node if + c_common_type returns error_mark_node. + 2016-06-19 Martin Sebor <msebor@redhat.com> PR c/69507 diff --git a/gcc/c/c-typeck.c b/gcc/c/c-typeck.c index f03c07bb7f1..7c6241c22d6 100644 --- a/gcc/c/c-typeck.c +++ b/gcc/c/c-typeck.c @@ -4846,6 +4846,8 @@ build_conditional_expr (location_t colon_loc, tree ifexp, bool ifexp_bcp, || code2 == COMPLEX_TYPE)) { result_type = c_common_type (type1, type2); + if (result_type == error_mark_node) + return error_mark_node; do_warn_double_promotion (result_type, type1, type2, "implicit conversion from %qT to %qT to " "match other result of conditional", diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index ce31fb71f5d..75bf51bb506 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2016-06-20 Joseph Myers <joseph@codesourcery.com> + + PR c/71601 + * gcc.dg/dfp/usual-arith-conv-bad-3.c: New test. + 2016-06-20 Jakub Jelinek <jakub@redhat.com> PR middle-end/71581 diff --git a/gcc/testsuite/gcc.dg/dfp/usual-arith-conv-bad-3.c b/gcc/testsuite/gcc.dg/dfp/usual-arith-conv-bad-3.c new file mode 100644 index 00000000000..95421a6bfb8 --- /dev/null +++ b/gcc/testsuite/gcc.dg/dfp/usual-arith-conv-bad-3.c @@ -0,0 +1,13 @@ +/* Test error for conditional expression between DFP and other + floating operand. */ +/* { dg-do compile } */ + +_Decimal32 a; +float b; +int i; + +void +f (void) +{ + (void) (i ? a : b); /* { dg-error "mix operands" } */ +} |