Fix ICE on conditional expression between DFP and non-DFP float (PR c/71601).
authorJoseph Myers <joseph@codesourcery.com>
Mon, 20 Jun 2016 22:58:20 +0000 (23:58 +0100)
committerJoseph Myers <jsm28@gcc.gnu.org>
Mon, 20 Jun 2016 22:58:20 +0000 (23:58 +0100)
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.

From-SVN: r237622

gcc/c/ChangeLog
gcc/c/c-typeck.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/dfp/usual-arith-conv-bad-3.c [new file with mode: 0644]

index bd25ecaec6ac323bdd74d8fdd2b0bf5ea18c2fb0..35b3de4a3659f0c075c9b0a4bbe263286c8c7abe 100644 (file)
@@ -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
index f03c07bb7f15d2e78c1579ac6a281e5a3dc695e4..7c6241c22d61fd163d4835be9163e5f635430cf8 100644 (file)
@@ -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",
index ce31fb71f5df66544438ebcbb33316b2579fc7c4..75bf51bb50667921fde2ecafed5debbe5c2cc78e 100644 (file)
@@ -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 (file)
index 0000000..95421a6
--- /dev/null
@@ -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" } */
+}