Patchwork Add __builtin_complex to construct complex values (C1X CMPLX* macros)

login
register
mail settings
Submitter Joseph S. Myers
Date Aug. 19, 2011, 9:56 p.m.
Message ID <Pine.LNX.4.64.1108192156130.13909@digraph.polyomino.org.uk>
Download mbox | patch
Permalink /patch/110741/
State New
Headers show

Comments

Joseph S. Myers - Aug. 19, 2011, 9:56 p.m.
On Fri, 19 Aug 2011, Jakub Jelinek wrote:

> On Fri, Aug 19, 2011 at 03:55:12PM +0000, Joseph S. Myers wrote:
> > Bootstrapped with no regressions on x86_64-unknown-linux-gnu.  Applied
> > to mainline.
> 
> The new tests ICE on i686-linux:
> FAIL: gcc.dg/builtin-complex-err-1.c (internal compiler error)
> FAIL: gcc.dg/builtin-complex-err-2.c (internal compiler error)
> FAIL: gcc.dg/torture/builtin-complex-1.c  -O*  (internal compiler error)
> 
> All the ICEs are on
>     case EXCESS_PRECISION_EXPR:
>       /* Each case where an operand with excess precision may be
>          encountered must remove the EXCESS_PRECISION_EXPR around
>          inner operands and possibly put one around the whole
>          expression or possibly convert to the semantic type (which
>          c_fully_fold does); we cannot tell at this stage which is
>          appropriate in any particular case.  */
>       gcc_unreachable ();
> in c_fully_fold_internal.

I've applied this patch that will hopefully fix the problem by
converting operands of __builtin_complex to their semantic types.
Bootstrapped with no regressions on x86_64-unknown-linux-gnu.

2011-08-19  Joseph Myers  <joseph@codesourcery.com>

	* c-parser.c (c_parser_postfix_expression): Convert operands of
	__builtin_complex to their semantic types.

Patch

Index: c-parser.c
===================================================================
--- c-parser.c	(revision 177911)
+++ c-parser.c	(working copy)
@@ -6428,7 +6428,13 @@  c_parser_postfix_expression (c_parser *p
 	  c_parser_skip_until_found (parser, CPP_CLOSE_PAREN,
 				     "expected %<)%>");
 	  mark_exp_read (e1.value);
+	  if (TREE_CODE (e1.value) == EXCESS_PRECISION_EXPR)
+	    e1.value = convert (TREE_TYPE (e1.value),
+				TREE_OPERAND (e1.value, 0));
 	  mark_exp_read (e2.value);
+	  if (TREE_CODE (e2.value) == EXCESS_PRECISION_EXPR)
+	    e2.value = convert (TREE_TYPE (e2.value),
+				TREE_OPERAND (e2.value, 0));
 	  if (!SCALAR_FLOAT_TYPE_P (TREE_TYPE (e1.value))
 	      || DECIMAL_FLOAT_TYPE_P (TREE_TYPE (e1.value))
 	      || !SCALAR_FLOAT_TYPE_P (TREE_TYPE (e2.value))