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] label_expr sanity check


Hi,
while debugging the nonlocal goto problem I added those two checks.
They may be usefull as it is quite easy to forget about
create_artifical_label and do it by hand (I managed to get one such case
into tree via older patch caught by Steven)

OK?
Honza

2003-11-13  Jan Hubicka  <jh@suse.cz>
	* gimplify.c (gimplify_expr): Check label_expr contexts.
	* tree-cfg.c (tree_verify_flow_info): Likewise.
Index: gimplify.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/gimplify.c,v
retrieving revision 1.1.2.111
diff -c -3 -p -r1.1.2.111 gimplify.c
*** gimplify.c	12 Nov 2003 22:06:25 -0000	1.1.2.111
--- gimplify.c	13 Nov 2003 00:26:07 -0000
*************** gimplify_expr (tree *expr_p, tree *pre_p
*** 2993,2998 ****
--- 2993,3002 ----
  
  	case LABEL_EXPR:
  	  ret = GS_ALL_DONE;
+ #ifdef ENABLE_CHECKING
+ 	  if (decl_function_context (LABEL_EXPR_LABEL (*expr_p)) != current_function_decl)
+ 	    abort ();
+ #endif
  	  break;
  
  	case CASE_LABEL_EXPR:
Index: tree-cfg.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-cfg.c,v
retrieving revision 1.1.4.210
diff -c -3 -p -r1.1.4.210 tree-cfg.c
*** tree-cfg.c	12 Nov 2003 23:33:07 -0000	1.1.4.210
--- tree-cfg.c	13 Nov 2003 00:26:08 -0000
*************** tree_verify_flow_info (void)
*** 2723,2729 ****
  	    break;
  	  if (label_to_block (LABEL_EXPR_LABEL (bsi_stmt (bsi))) != bb)
  	    {
! 	      error ("Label to block does not match in bb %d\n", bb->index);
  	      err = 1;
  	    }
  	}
--- 2725,2741 ----
  	    break;
  	  if (label_to_block (LABEL_EXPR_LABEL (bsi_stmt (bsi))) != bb)
  	    {
! 	      error ("Label %s to block does not match in bb %d\n",
! 		     IDENTIFIER_POINTER (DECL_NAME (bsi_stmt (bsi))),
! 		     bb->index);
! 	      err = 1;
! 	    }
! 	  if (decl_function_context (LABEL_EXPR_LABEL (bsi_stmt (bsi)))
! 	      != current_function_decl)
! 	    {
! 	      error ("Label %s does not match in bb %d\n",
! 		     IDENTIFIER_POINTER (DECL_NAME (bsi_stmt (bsi))),
! 		     bb->index);
  	      err = 1;
  	    }
  	}


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