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] PR c/18867


Hi,

This is a regression introduced by my 2004-07-20 changes to the C front
end.  We should set orig_type to error_mark_node when the type for the
controlling expression of a switch does not have integer type.

Test case (testsuite/gcc.dg/noncompile/20041207.c):
---------------------------------
/* PR18867 - ICE on a switch controlling expressions with an
   invalid type.  Origin: Serge Belyshev <belyshev@lubercy.com>  */
   
void f()
{
  float x;
  switch (x) {case 0: break;}; /* {dg-error "not an integer" } */
}
---------------------------------

Bootstrapped and tested on x86_64-suse-linux-gnu, OK?

Gr.
Steven



	PR c/18867
	* c-typeck.c (c_start_case): Set orig_type to error_mark_node
	when the type of the controlling expression is not a valid type.

testsuite/
	* gcc.dg/noncompile/20041207.c: New test.


Index: c-typeck.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-typeck.c,v
retrieving revision 1.402
diff -c -3 -p -r1.402 c-typeck.c
*** c-typeck.c	5 Dec 2004 15:31:02 -0000	1.402
--- c-typeck.c	7 Dec 2004 18:59:12 -0000
*************** c_start_case (tree exp)
*** 6507,6512 ****
--- 6507,6513 ----
  	{
  	  error ("switch quantity not an integer");
  	  exp = integer_zero_node;
+ 	  orig_type = error_mark_node;
  	}
        else
  	{


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