This is the mail archive of the 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]

[C PATCH] PR middle-end/27428: error_mark_node during gimplification

Hi Joseph,

The following patch resolves PR middle-end/27428 which is a P2
ICE-on-invalid regression affecting all active branches.  The
issue is, as suspected by Mark in comment #4, that for this example
in the PR, we're managing to pass a tree containing an error_mark_node
into the middle-end's tree lowering machinery, after encountering a
compiler error.  Normally, we have checks to prevent this from
happening and not bother lowering trees after spewing an error.

This particular case is exceptional, as it's libcpp that encounters
and issues the diagnostic error message, and c-lex.c that then
simply returns error_mark_node.  Alas, this combination means that
the gcc/'s diagnostic and error tracking machinery doesn't realize
that anything has gone wrong and errorcount remains zero.  Doh!

The fix below is to manually increment errorcount in c_lex_with_flags
when we return an error_mark_node after libcpp has issued the error
message for us.  A quick inspection reveals that this is the only
place that error_mark_node is mentioned in c-lex.c, which probably
plugs this class of errors.

The following patch has been tested on i686-pc-linux-gnu with a full
"make bootstrap", all default languages including Ada, and regression
tested with a top-level "make -k check" with no new failures.

Ok for mainline?  And the gcc 4.0 and 4.1 branches after a while?
Thanks in advance,

2006-06-28  Roger Sayle  <>

	PR middle-end/27428
	* c-lex.c (c_lex_with_flags) <CPP_N_INVALID>: Increment errorcount
	to indicate the cpplib has issued an error message for us.

	* gcc.dg/pr27428-1.c: New test case.

Index: c-lex.c
*** c-lex.c	(revision 114994)
--- c-lex.c	(working copy)
*************** c_lex_with_flags (tree *value, location_
*** 364,369 ****
--- 364,370 ----
  	  case CPP_N_INVALID:
  	    /* cpplib has issued an error.  */
  	    *value = error_mark_node;
+ 	    errorcount++;

  	  case CPP_N_INTEGER:

/* { dg-do compile } */
/* { dg-options "-O2" } */

void foo()
    goto L;
    if (0..) { L: ; }  // { dg-error "too many decimal points" }


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