public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] PR c/7128: ICE in c_expand_asm_operands
@ 2002-11-03 15:36 Roger Sayle
  2002-11-03 16:02 ` Richard Henderson
  2002-11-04  1:25 ` Joseph S. Myers
  0 siblings, 2 replies; 4+ messages in thread
From: Roger Sayle @ 2002-11-03 15:36 UTC (permalink / raw)
  To: gcc-patches


Whilst tinkering with glibc's soft-fp library, I discovered an
ICE on invalid input in c_expand_asm_operands.  Checking with
GNATS, this problem is already reported as PR c/7128.

The patch below cures the problem by checking for error_mark_nodes
in the "outputs" array argument before processing or deferencing
its members.

The patch below has survived a complete "make bootstrap" (all
languages except Ada and treelang) on both i686-pc-cygwin and
i686-pc-linux-gnu, where a "make -k check" reveals no new
regressions.  It resolves both my ICE and the example listed
in GNATS PR c/7128.


Ok for mainline and to close PR c/7128?


2002-11-03  Roger Sayle  <roger@eyesopen.com>

	PR c/7128
	* c-typeck.c (c_expand_asm_operands): Defend against
	error_mark_nodes in argument "output" to avoid ICE.


Index: c-typeck.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-typeck.c,v
retrieving revision 1.211
diff -c -3 -p -r1.211 c-typeck.c
*** c-typeck.c	26 Oct 2002 01:18:52 -0000	1.211
--- c-typeck.c	3 Nov 2002 15:41:44 -0000
*************** c_expand_asm_operands (string, outputs,
*** 6957,6963 ****

    /* Record the contents of OUTPUTS before it is modified.  */
    for (i = 0, tail = outputs; tail; tail = TREE_CHAIN (tail), i++)
!     o[i] = TREE_VALUE (tail);

    /* Generate the ASM_OPERANDS insn; store into the TREE_VALUEs of
       OUTPUTS some trees for where the values were actually stored.  */
--- 6957,6967 ----

    /* Record the contents of OUTPUTS before it is modified.  */
    for (i = 0, tail = outputs; tail; tail = TREE_CHAIN (tail), i++)
!     {
!       o[i] = TREE_VALUE (tail);
!       if (o[i] == error_mark_node)
! 	return;
!     }

    /* Generate the ASM_OPERANDS insn; store into the TREE_VALUEs of
       OUTPUTS some trees for where the values were actually stored.  */

Roger
--
Roger Sayle,                         E-mail: roger@eyesopen.com
OpenEye Scientific Software,         WWW: http://www.eyesopen.com/
Suite 1107, 3600 Cerrillos Road,     Tel: (+1) 505-473-7385
Santa Fe, New Mexico, 87507.         Fax: (+1) 505-473-0833

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

* Re: [PATCH] PR c/7128: ICE in c_expand_asm_operands
  2002-11-03 15:36 [PATCH] PR c/7128: ICE in c_expand_asm_operands Roger Sayle
@ 2002-11-03 16:02 ` Richard Henderson
  2002-11-04  1:25 ` Joseph S. Myers
  1 sibling, 0 replies; 4+ messages in thread
From: Richard Henderson @ 2002-11-03 16:02 UTC (permalink / raw)
  To: Roger Sayle; +Cc: gcc-patches

On Sun, Nov 03, 2002 at 04:21:41PM -0700, Roger Sayle wrote:
> 	PR c/7128
> 	* c-typeck.c (c_expand_asm_operands): Defend against
> 	error_mark_nodes in argument "output" to avoid ICE.

Ok.


r~

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

* Re: [PATCH] PR c/7128: ICE in c_expand_asm_operands
  2002-11-03 15:36 [PATCH] PR c/7128: ICE in c_expand_asm_operands Roger Sayle
  2002-11-03 16:02 ` Richard Henderson
@ 2002-11-04  1:25 ` Joseph S. Myers
  2002-11-07 21:26   ` [PATCH] New testcase for PR c/7128 Roger Sayle
  1 sibling, 1 reply; 4+ messages in thread
From: Joseph S. Myers @ 2002-11-04  1:25 UTC (permalink / raw)
  To: Roger Sayle; +Cc: gcc-patches

On Sun, 3 Nov 2002, Roger Sayle wrote:

> 2002-11-03  Roger Sayle  <roger@eyesopen.com>
> 
> 	PR c/7128
> 	* c-typeck.c (c_expand_asm_operands): Defend against
> 	error_mark_nodes in argument "output" to avoid ICE.

Testcase for testsuite?

-- 
Joseph S. Myers
jsm28@cam.ac.uk

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

* [PATCH] New testcase for PR c/7128
  2002-11-04  1:25 ` Joseph S. Myers
@ 2002-11-07 21:26   ` Roger Sayle
  0 siblings, 0 replies; 4+ messages in thread
From: Roger Sayle @ 2002-11-07 21:26 UTC (permalink / raw)
  To: gcc-patches; +Cc: Joseph S. Myers


On Mon, 4 Nov 2002, Joseph S. Myers wrote:
> > 2002-11-03  Roger Sayle  <roger@eyesopen.com>
> >
> > 	PR c/7128
> > 	* c-typeck.c (c_expand_asm_operands): Defend against
> > 	error_mark_nodes in argument "output" to avoid ICE.
>
> Testcase for testsuite?

Sorry for the delay (Rosemary Elizabeth Sayle was born 2:08pm
on Tuesday November 5th, 6lbs 15oz :>).

The following patch adds a testcase for the recently fixed GNATS
PR c/7128.  I've tested that this PASSes with current mainline
on i686-pc-linux-gnu but FAILs without my recent patch.  Interestingly
this is only the second testcase to check for an undeclared identifier.
I've also checked that the __asm__ is portable by failing to compile
on alpha/Tru64, sparc/Solaris and parisc/HPUX.

Ok for mainline?


2002-11-07  Roger Sayle  <roger@eyesopen.com>

	* gcc.dg/20021107-1.c: New testcase for PR c/7128.


*** /dev/null	Thu Aug 30 14:30:55 2001
--- gcc.dg/20021107-1.c	Mon Nov  4 14:15:06 2002
***************
*** 0 ****
--- 1,15 ----
+ /* Copyright (C) 2002 Free Software Foundation.
+
+    Test for PR c/7128, ICE on invalid code in c_expand_asm_operands.
+
+    Extracted from GNAT PR by Roger Sayle, 4th November 2002.  */
+
+ /* { dg-do compile } */
+
+ void foo ()
+ {
+   __asm__ ("foo %0" : "=r" (r));
+   /* { dg-error "undeclared"     "undeclared" { target *-*-* } { 11 } } */
+   /* { dg-error "each function it appears" "" { target *-*-* } { 11 } } */
+ }
+

Roger
--
Roger Sayle,                         E-mail: roger@eyesopen.com
OpenEye Scientific Software,         WWW: http://www.eyesopen.com/
Suite 1107, 3600 Cerrillos Road,     Tel: (+1) 505-473-7385
Santa Fe, New Mexico, 87507.         Fax: (+1) 505-473-0833

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

end of thread, other threads:[~2002-11-08  5:26 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-11-03 15:36 [PATCH] PR c/7128: ICE in c_expand_asm_operands Roger Sayle
2002-11-03 16:02 ` Richard Henderson
2002-11-04  1:25 ` Joseph S. Myers
2002-11-07 21:26   ` [PATCH] New testcase for PR c/7128 Roger Sayle

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).