This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] avoid c-typeck.c ICE for mixed binary/decimal operations


This patch fixes an internal compiler error for some expressions mixing
decimal float and binary float operands.

Bootstrapped and regression tested on powerpc64-linux, OK for mainline?

2007-05-14  Janis Johnson  <janis187@us.ibm.com>

gcc/
	* c-typeck.c (build_binary_op): Return early for error.
gcc/testsuite/
	* gcc.dg/dfp/usual-arith-conv-bad.c: New test.

Index: gcc/c-typeck.c
===================================================================
--- gcc/c-typeck.c	(revision 124664)
+++ gcc/c-typeck.c	(working copy)
@@ -8148,7 +8148,11 @@
       int none_complex = (code0 != COMPLEX_TYPE && code1 != COMPLEX_TYPE);
 
       if (shorten || common || short_compare)
-	result_type = c_common_type (type0, type1);
+	{
+	  result_type = c_common_type (type0, type1);
+	  if (result_type == error_mark_node)
+	    return error_mark_node;
+	}
 
       /* For certain operations (which identify themselves by shorten != 0)
 	 if both args were extended from the same smaller type,
Index: gcc/testsuite/gcc.dg/dfp/usual-arith-conv-bad-2.c
===================================================================
--- gcc/testsuite/gcc.dg/dfp/usual-arith-conv-bad-2.c	(revision 0)
+++ gcc/testsuite/gcc.dg/dfp/usual-arith-conv-bad-2.c	(revision 0)
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
+
+/* This used to result in an ICE.  */
+
+extern _Decimal64 x;
+extern int i;
+
+void
+foo (void)
+{
+  if (x <= 2.0)		/* { dg-error "mix operands" } */
+    i++;
+}


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]