public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] avoid c-typeck.c ICE for mixed binary/decimal operations
@ 2007-05-14 22:33 Janis Johnson
  2007-05-14 23:19 ` Joseph S. Myers
  0 siblings, 1 reply; 2+ messages in thread
From: Janis Johnson @ 2007-05-14 22:33 UTC (permalink / raw)
  To: gcc-patches

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++;
+}

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] avoid c-typeck.c ICE for mixed binary/decimal operations
  2007-05-14 22:33 [PATCH] avoid c-typeck.c ICE for mixed binary/decimal operations Janis Johnson
@ 2007-05-14 23:19 ` Joseph S. Myers
  0 siblings, 0 replies; 2+ messages in thread
From: Joseph S. Myers @ 2007-05-14 23:19 UTC (permalink / raw)
  To: Janis Johnson; +Cc: gcc-patches

On Mon, 14 May 2007, Janis Johnson wrote:

> 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?

OK.

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2007-05-14 23:19 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-05-14 22:33 [PATCH] avoid c-typeck.c ICE for mixed binary/decimal operations Janis Johnson
2007-05-14 23:19 ` Joseph S. Myers

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).