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]

[tree-ssa] fix c empty switch abort


Exposed by one of the Wswitch tests like so:

	switch (i)
	{
	}

The gimplifier takes null SWITCH_BODY to mean that it's already
collected the SWITCH_LABELS.  If it finds that's null too, boom.


r~

        * c-simplify.c (gimplify_switch_stmt): Force switch body non-null.

Index: c-simplify.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/c-simplify.c,v
retrieving revision 1.1.4.77
diff -c -p -d -r1.1.4.77 c-simplify.c
*** c-simplify.c	30 Oct 2003 02:49:40 -0000	1.1.4.77
--- c-simplify.c	31 Oct 2003 07:03:50 -0000
*************** static void
*** 778,791 ****
  gimplify_switch_stmt (tree *stmt_p)
  {
    tree stmt = *stmt_p;
!   tree break_block;
    location_t stmt_locus = input_location;
  
    break_block = begin_bc_block (bc_break);
  
    gimplify_condition (&SWITCH_COND (stmt));
    *stmt_p = build (SWITCH_EXPR, SWITCH_TYPE (stmt), SWITCH_COND (stmt),
! 		   SWITCH_BODY (stmt), NULL_TREE);
    annotate_with_locus (*stmt_p, stmt_locus);
    gimplify_stmt (stmt_p);
  
--- 778,796 ----
  gimplify_switch_stmt (tree *stmt_p)
  {
    tree stmt = *stmt_p;
!   tree break_block, body;
    location_t stmt_locus = input_location;
  
    break_block = begin_bc_block (bc_break);
  
    gimplify_condition (&SWITCH_COND (stmt));
+ 
+   body = SWITCH_BODY (stmt);
+   if (!body)
+     body = build_empty_stmt ();
+ 
    *stmt_p = build (SWITCH_EXPR, SWITCH_TYPE (stmt), SWITCH_COND (stmt),
! 		   body, NULL_TREE);
    annotate_with_locus (*stmt_p, stmt_locus);
    gimplify_stmt (stmt_p);
  


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