diff -r 349f85192e52 d/d-codegen.cc
--- a/d/d-codegen.cc	Wed Aug 11 18:45:39 2010 +0100
+++ b/d/d-codegen.cc	Fri Aug 13 00:52:16 2010 +0100
@@ -3069,7 +3069,7 @@
 {
     tree t_cond = convertForCondition(e_cond);
 
-    Flow * f = beginFlow(stmt/*, 0*/);
+    Flow * f = beginFlow(stmt);
     f->condition = t_cond;
 }
 
@@ -3101,7 +3101,7 @@
 
 void
 IRState::startLoop(Statement * stmt) {
-    Flow * f = beginFlow(stmt/*, Break|Continue*/);
+    Flow * f = beginFlow(stmt);
     f->continueLabel = label(stmt ? stmt->loc : 0); // should be end for 'do' loop
 }
 
diff -r 349f85192e52 d/d-codegen.h
--- a/d/d-codegen.h	Wed Aug 11 18:45:39 2010 +0100
+++ b/d/d-codegen.h	Fri Aug 13 00:52:16 2010 +0100
@@ -520,6 +520,8 @@
     void doAsm(tree insn_tmpl, tree outputs, tree inputs, tree clobbers);
 
     // ** Callback statement evalutation
+    
+    unsigned * switchStatement; // %%
 
     static Array stmtExprList;
     
diff -r 349f85192e52 d/d-glue.cc
--- a/d/d-glue.cc	Wed Aug 11 18:45:39 2010 +0100
+++ b/d/d-glue.cc	Fri Aug 13 00:52:16 2010 +0100
@@ -3762,13 +3762,30 @@
 void
 TryFinallyStatement::toIR(IRState * irs)
 {
+#if D_GCC_VER < 40
     // %% doc: this is not the same as a start_eh/end_eh_cleanup sequence
     tree t_body = body ? irs->makeStmtExpr(body) : d_void_zero_node;
     tree t_finl = finalbody ? irs->makeStmtExpr(finalbody) : d_void_zero_node;
     tree tf = build2(TRY_FINALLY_EXPR, void_type_node, t_body, t_finl);
     // TREE_SIDE_EFFECTS(tf) = 1; // probably not needed
     irs->doLineNote(loc);
+    irs->startScope(); // %% try block is a new scope.
     irs->doExp(tf);
+    irs->endScope();
+#else
+    irs->doLineNote(loc);
+    irs->startScope();
+
+    irs->startTry(this);
+    if (body)
+	body->toIR(irs);
+    irs->startFinally();
+    if (finalbody)
+	finalbody->toIR(irs);
+    irs->endFinally();
+
+    irs->endScope();
+#endif
 }
 
 void
@@ -3897,7 +3914,7 @@
 	g.ofile->rodc(critsec_decl, 1);
 
 #if D_GCC_VER < 40
-	expand_eh_region_start();	
+	expand_eh_region_start();
 	expand_expr_stmt_value(irs->libCall(LIBCALL_CRITICALENTER, 1, & critsec_ref), 0, 1);
 	if (body)
 	    body->toIR( irs );
@@ -3963,6 +3980,8 @@
 void
 DefaultStatement::toIR(IRState * irs)
 {
+    if( irs->parentScope() != irs->switchStatement )
+	error("default cannot be in different try block level from switch");
     irs->doCase(NULL_TREE, cblock);
     if (statement)
 	statement->toIR( irs );
@@ -3973,6 +3992,9 @@
 {
     tree case_value;
 
+    if( irs->parentScope() != irs->switchStatement )
+	error("case cannot be in different try block level from switch");
+
     if ( exp->type->isscalar() )
 	case_value = exp->toElem(irs);
     else
@@ -3988,6 +4010,7 @@
     tree cond_tree;
     // %% also what about c-semantics doing emit_nop() ?
     irs->doLineNote( loc );
+    irs->switchStatement = irs->currentScope();
 
     cond_tree = condition->toElem( irs );
 
diff -r 349f85192e52 d/d-irstate.cc
--- a/d/d-irstate.cc	Wed Aug 11 18:45:39 2010 +0100
+++ b/d/d-irstate.cc	Fri Aug 13 00:52:16 2010 +0100
@@ -293,7 +293,7 @@
 #else
 
 IRBase::Flow *
-IRBase::beginFlow(Statement * stmt/*, int labels*/)
+IRBase::beginFlow(Statement * stmt)
 {
     Flow * flow = new Flow;
     
@@ -301,16 +301,6 @@
     flow->exitLabel = NULL_TREE;
     flow->condition = NULL_TREE;
     flow->trueBranch = NULL_TREE;
-    /*
-    if (labels & Break)
-	flow->exitLabel = error_mark_node; // don't create until needed
-    if (labels & Continue) {
-	flow->continueLabel = build_decl(LABEL_DECL, NULL, void_type_node);
-	DECL_CONTEXT( flow->continueLabel ) = getLocalContext();
-	//used,mode?
-    }
-    flow->exitLabel = NULL;
-    */
     
     loops.push(flow);
 
diff -r 349f85192e52 d/d-irstate.h
--- a/d/d-irstate.h	Wed Aug 11 18:45:39 2010 +0100
+++ b/d/d-irstate.h	Fri Aug 13 00:52:16 2010 +0100
@@ -118,8 +118,7 @@
 #if D_GCC_VER < 40    
     Flow *    beginFlow(Statement * stmt, nesting * loop);
 #else
-    //typedef enum { Break = 0x1, Continue = 0x2 } FlowLabel;
-    Flow *    beginFlow(Statement * stmt/*, int labels*/);
+    Flow *    beginFlow(Statement * stmt);
 #endif
     void      endFlow();
     Flow *    currentFlow() { return (Flow *) loops.tos(); }
@@ -137,7 +136,7 @@
        a new scope. (And for now, until the emitLocalVar crash is
        solved, this also creates a default binding contour.)
        
-       "Binding countour": Same as GCC's definition, whatever that is.
+       "Binding contour": Same as GCC's definition, whatever that is.
        Each user-declared variable will have a binding contour that begins
        where the variable is declared and ends at it's containing scope.
     */
@@ -146,6 +145,15 @@
     void startScope();
     void endScope();
 
+    unsigned * currentScope() {
+	return ((unsigned *)scopes.tos());
+    }
+    unsigned * parentScope() {
+	return scopes.dim > 1
+	    ? ((unsigned *)scopes.data[scopes.dim-2])
+	    : currentScope();
+    }
+
     void startBindings();
     void endBindings();
 
