This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
PATCH for sanity checking of nesting code
- To: gcc-patches at gcc dot gnu dot org
- Subject: PATCH for sanity checking of nesting code
- From: Jason Merrill <jason_merrill at redhat dot com>
- Date: 08 Jun 2001 22:56:53 +0100
I've had this in my tree for a few weeks, since I tracked down a bug
involving mismatched push/pops and EH.
Applied to trunk.
2001-06-08 Jason Merrill <jason_merrill@redhat.com>
* stmt.c (current_nesting_level): New fn.
* tree.h: Declare it.
* c-semantics.c (genrtl_compound_stmt): Use it.
*** c-semantics.c.~1~ Wed Jun 6 15:20:55 2001
--- c-semantics.c Fri Jun 8 17:30:20 2001
*************** void
*** 666,672 ****
--- 666,682 ----
genrtl_compound_stmt (t)
tree t;
{
+ #ifdef ENABLE_CHECKING
+ struct nesting *n = current_nesting_level ();
+ #endif
+
expand_stmt (COMPOUND_BODY (t));
+
+ #ifdef ENABLE_CHECKING
+ /* Make sure that we've pushed and popped the same number of levels. */
+ if (n != current_nesting_level ())
+ abort ();
+ #endif
}
/* Generate the RTL for an ASM_STMT. */
*** stmt.c.~1~ Wed Jun 6 15:20:55 2001
--- stmt.c Mon May 21 17:04:43 2001
*************** conditional_context ()
*** 3395,3400 ****
--- 3395,3409 ----
return block_stack && block_stack->data.block.conditional_code;
}
+ /* Return an opaque pointer to the current nesting level, so frontend code
+ can check its own sanity. */
+
+ struct nesting *
+ current_nesting_level ()
+ {
+ return cfun ? block_stack : 0;
+ }
+
/* Emit a handler label for a nonlocal goto handler.
Also emit code to store the handler label in SLOT before BEFORE_INSN. */
*** tree.h.~1~ Wed Jun 6 15:20:55 2001
--- tree.h Fri Jun 8 19:05:33 2001
*************** extern void end_cleanup_deferral PARAMS
*** 2564,2569 ****
--- 2567,2573 ----
extern int is_body_block PARAMS ((tree));
extern int conditional_context PARAMS ((void));
+ extern struct nesting * current_nesting_level PARAMS ((void));
extern tree last_cleanup_this_contour PARAMS ((void));
extern void expand_start_case PARAMS ((int, tree, tree,
const char *));