Index: src/tests/.expect/dtor-early-exit-ERR1.txt
===================================================================
--- src/tests/.expect/dtor-early-exit-ERR1.txt	(revision 85f07136d59ad0958d13142535210855683cd8a9)
+++ src/tests/.expect/dtor-early-exit-ERR1.txt	(revision 85f07136d59ad0958d13142535210855683cd8a9)
@@ -0,0 +1,4 @@
+CFA Version 1.0.0 (debug)
+Error: jump to label 'L1' crosses initialization of y Branch (Goto)
+
+make: *** [dtor-early-exit-ERR1] Error 1
Index: src/tests/.expect/dtor-early-exit-ERR2.txt
===================================================================
--- src/tests/.expect/dtor-early-exit-ERR2.txt	(revision 85f07136d59ad0958d13142535210855683cd8a9)
+++ src/tests/.expect/dtor-early-exit-ERR2.txt	(revision 85f07136d59ad0958d13142535210855683cd8a9)
@@ -0,0 +1,4 @@
+CFA Version 1.0.0 (debug)
+Error: jump to label 'L2' crosses initialization of y Branch (Goto)
+
+make: *** [dtor-early-exit-ERR2] Error 1
Index: src/tests/.expect/dtor-early-exit.txt
===================================================================
--- src/tests/.expect/dtor-early-exit.txt	(revision 85f07136d59ad0958d13142535210855683cd8a9)
+++ src/tests/.expect/dtor-early-exit.txt	(revision 85f07136d59ad0958d13142535210855683cd8a9)
@@ -0,0 +1,214 @@
+f i=0
+construct x
+construct y
+construct z
+destruct z
+destruct y
+destruct x
+f i=1
+construct x
+construct y
+construct z
+destruct z
+destruct y
+destruct x
+f i=2
+construct x
+construct y
+construct z
+destruct z
+destruct y
+destruct x
+f i=3
+construct x
+construct y
+construct z
+destruct z
+destruct y
+destruct x
+
+g for i=0
+construct x
+destruct x
+g for i=1
+construct x
+destruct x
+g for i=2
+construct x
+destruct x
+g for i=3
+construct x
+destruct x
+g for i=4
+construct x
+destruct x
+g for i=5
+construct x
+destruct x
+g for i=6
+construct x
+destruct x
+g for i=7
+construct x
+destruct x
+g for i=8
+construct x
+destruct x
+g for i=9
+construct x
+destruct x
+
+g while i=0
+construct x
+destruct x
+g while i=1
+construct x
+destruct x
+g while i=2
+construct x
+destruct x
+g while i=3
+construct x
+destruct x
+g while i=4
+construct x
+destruct x
+g while i=5
+construct x
+destruct x
+g while i=6
+construct x
+destruct x
+g while i=7
+construct x
+destruct x
+g while i=8
+construct x
+destruct x
+g while i=9
+construct x
+destruct x
+
+construct y
+g switch i=0
+destruct y
+construct y
+g switch i=1
+destruct y
+construct y
+g switch i=2
+destruct y
+construct y
+g switch i=3
+destruct y
+construct y
+g switch i=4
+destruct y
+construct y
+g switch i=5
+destruct y
+construct y
+g switch i=6
+destruct y
+construct y
+g switch i=7
+destruct y
+construct y
+g switch i=8
+destruct y
+construct y
+g switch i=9
+destruct y
+
+g for k=0
+g for i=0
+construct x
+g for j=0
+construct y
+continue L2
+destruct y
+g for j=1
+construct y
+break L2
+destruct y
+destruct x
+g for i=1
+construct x
+g for j=0
+construct y
+continue L2
+destruct y
+g for j=1
+construct y
+break L2
+destruct y
+destruct x
+g for i=2
+construct x
+continue L1
+destruct x
+g for i=3
+construct x
+break L1
+destruct x
+g for k=1
+g for i=0
+construct x
+g for j=0
+construct y
+continue L2
+destruct y
+g for j=1
+construct y
+break L2
+destruct y
+destruct x
+g for i=1
+construct x
+g for j=0
+construct y
+continue L2
+destruct y
+g for j=1
+construct y
+break L2
+destruct y
+destruct x
+g for i=2
+construct x
+continue L1
+destruct x
+g for i=3
+construct x
+break L1
+destruct x
+
+h
+construct y
+L1
+construct x
+L2
+goto L1
+destruct x
+L1
+construct x
+L2
+goto L2
+L2
+goto L3
+L3
+goto L2-2
+L2
+goto L4
+destruct x
+destruct y
+L4
+goto L0
+construct y
+L1
+construct x
+L2
+goto L4
+destruct x
+destruct y
+L4
Index: src/tests/Makefile.am
===================================================================
--- src/tests/Makefile.am	(revision 4b2589a5585c447a4b3ff6c5524c919a032e22a4)
+++ src/tests/Makefile.am	(revision 85f07136d59ad0958d13142535210855683cd8a9)
@@ -46,2 +46,9 @@
 constant0-1NDDP : constant0-1.c
 	${CC} ${CFLAGS} -DNEWDECL -DDUPS ${<} -o ${@}
+
+dtor-early-exit-ERR1: dtor-early-exit.c
+	${CC} ${CFLAGS} -DERR1 ${<} -o ${@}
+
+dtor-early-exit-ERR2: dtor-early-exit.c
+	${CC} ${CFLAGS} -DERR2 ${<} -o ${@}
+
Index: src/tests/Makefile.in
===================================================================
--- src/tests/Makefile.in	(revision 4b2589a5585c447a4b3ff6c5524c919a032e22a4)
+++ src/tests/Makefile.in	(revision 85f07136d59ad0958d13142535210855683cd8a9)
@@ -654,4 +654,10 @@
 	${CC} ${CFLAGS} -DNEWDECL -DDUPS ${<} -o ${@}
 
+dtor-early-exit-ERR1: dtor-early-exit.c
+	${CC} ${CFLAGS} -DERR1 ${<} -o ${@}
+
+dtor-early-exit-ERR2: dtor-early-exit.c
+	${CC} ${CFLAGS} -DERR2 ${<} -o ${@}
+
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
 # Otherwise a system limit (for SysV at least) may be exceeded.
Index: src/tests/dtor-early-exit.c
===================================================================
--- src/tests/dtor-early-exit.c	(revision 85f07136d59ad0958d13142535210855683cd8a9)
+++ src/tests/dtor-early-exit.c	(revision 85f07136d59ad0958d13142535210855683cd8a9)
@@ -0,0 +1,207 @@
+#include <fstream>
+#include <stdlib>
+extern "C" {
+#define false ((int)0)	// until stdbool.h works
+#define assert(cond) if (! (cond)) { sout | "Assertion failed: (" | #cond | ") at " __FILE__ | ":" | __LINE__ | endl; abort(); }
+}
+
+struct A {
+	char * name;
+	int * x;
+};
+
+// don't want these called
+void ?{}(A * a) { assert( false ); }
+void ?{}(A * a, char * name) { a->name = name; sout | "construct " | name | endl; a->x = malloc(); }
+void ?{}(A * a, char * name, int * ptr) { assert( false ); }
+
+A ?=?(A * a, A a) {  sout | "assign " | a->name | " " | a.name; return a; }
+void ?{}(A * a, A a) { sout | "copy construct " | a.name | endl; a->x = malloc(); }
+void ^?{}(A * a) { sout | "destruct " | a->name | endl; free(a->x); }
+
+// test returns
+void f(int i) {
+	sout | "f i=" | i | endl;
+	A x = { "x" };  // construct x
+	{
+		A y = { "y" }; // construct y
+		{
+			A z = { "z" }; // construct z
+			{
+				if (i == 0) return; // destruct x, y, z
+			}
+			if (i == 1) return; // destruct x, y, z
+			// destruct z
+		}
+		if (i == 2) return; // destruct x, y
+		// destruct y
+	}
+	return; // destruct x
+}
+
+// test loops, switch, etc.
+void g() {
+	for (int i = 0; i < 10; i++) {
+		sout | "g for i=" | i | endl;
+		A x = { "x" };
+		// construct x
+		// destruct x
+	}
+	sout | endl;
+	{
+		int i = 0;
+		while (i < 10) {
+			sout | "g while i=" | i | endl;
+			A x = { "x" };
+			// construct x
+			i++;
+			// destruct x
+		}
+	}
+	sout | endl;
+	for (int i = 0; i < 10; i++) {
+		switch(10) {
+			case 0:
+			case 5:
+			case 10: {
+				A y = { "y" };
+				sout | "g switch i=" | i | endl;
+				// construct y
+				break; // destruct y
+			}
+			default: {
+				sout | "g switch i=" | i | endl;
+				A x = { "x" };
+				// construct x
+				break; // destruct x
+			}
+		}
+	}
+	sout | endl;
+	for (int k = 0; k < 2; k++) {
+		sout | "g for k=" | k | endl;
+		L1: for (int i = 0; i < 10; i++) {
+			sout | "g for i=" | i | endl;
+
+			A x = { "x" };
+			if (i == 2) {
+				sout | "continue L1" | endl;
+				continue;  // destruct x
+			} else if (i == 3) {
+				sout | "break L1" | endl;
+				break;  // destruct x
+			}
+
+			L2: for (int j = 0; j < 10; j++) {
+				sout | "g for j=" | j | endl;
+				A y = { "y" };
+				if (j == 0) {
+					sout | "continue L2" | endl;
+					continue; // destruct y - missing because object that needs to be destructed is not a part of this block, it's a part of the for's block
+				} else if (j == 1) {
+					sout | "break L2" | endl;
+					break;  // destruct y
+				} else if (i == 1) {
+					sout | "continue L1" | endl;
+					continue L1; // destruct x,y - note: continue takes you to destructors for block, so only generate destructor for y
+				} else if (k == 1) {
+					sout | "break L1" | endl;
+					break L1;  // destruct x,y
+				}
+			}
+		}
+	}
+}
+
+// test goto
+void h() {
+	int i = 0;
+	// for each goto G with target label L:
+	// * find all constructed variables alive at G (set S_G)
+	// * find all constructed variables alive at L (set S_L)
+	// * if S_L-S_G is non-empty, error
+	// * emit destructors for all variables in S_G-S_L
+	sout | "h" | endl;
+	{
+		L0: ;
+#ifdef ERR1
+			goto L1; // this is an error in g++ because it skips initialization of y
+#endif
+			A y = { "y" };
+			// S_L1 = { y }
+		L1: sout | "L1" | endl;
+			A x = { "x" };
+			// S_L2 = { y, x }
+		L2: sout | "L2" | endl;
+			if (i == 0) {
+				++i;
+				sout | "goto L1" | endl;
+				// S_G = { y, x }
+				goto L1;  // jump back, destruct b/c before x definition
+				// S_L-S_G = {} => no error
+				// S_G-S_L = { x } => destruct x
+			} else if (i == 1) {
+				++i;
+				sout | "goto L2" | endl;
+				// S_G = { y, x }
+				goto L2;  // jump back, do not destruct
+				// S_L-S_G = {}
+				// S_G-S_L = {} => destruct nothing
+			} else if (i == 2) {
+				++i;
+				sout | "goto L3" | endl;
+				// S_G = { y, x }
+				goto L3;  // jump ahead, do not destruct
+				// S_L-S_G = {}
+				// S_G-S_L = {}
+			} else if (false) {
+				++i;
+				A z = { "z" };
+				sout | "goto L3-2" | endl;
+				// S_G = { z, y, x }
+				goto L3;
+				// S_L-S_G = {}
+				// S_G-S_L = {z} => destruct z
+			} else {
+				++i;
+				sout | "goto L4" | endl;
+				// S_G = { y, x }
+				goto L4;  // jump ahead, destruct b/c left block x was defined in
+				// S_L-S_G = {}
+				// S_G-S_L = { y, x } => destruct y, x
+			}
+			// S_L3 = { y, x }
+		L3: sout | "L3" | endl;
+			sout | "goto L2-2" | endl;
+			// S_G = { y, x }
+			goto L2; // jump back, do not destruct
+			// S_L-S_G = {}
+			// S_G-S_L = {}
+	}
+	// S_L4 = {}
+	L4: sout | "L4" | endl;
+	if (i == 4) {
+		sout | "goto L0" | endl;
+		// S_G = {}
+		goto L0;
+		// S_L-S_G = {}
+		// S_G-S_L = {}
+	}
+	// S_G = {}
+#ifdef ERR2
+	if (i == 5) goto L2; // this is an error in g++ because it skips initialization of y, x
+	// S_L-S_G = { y, x } => non-empty, so error
+#endif
+}
+
+int main() {
+	sepDisable(sout);
+	for (int i = 0; i < 4; i++) {
+		f(i);
+	}
+	sout | endl;
+	g();
+	sout | endl;
+	h();
+}
+
Index: src/tests/init_once.c
===================================================================
--- src/tests/init_once.c	(revision 85f07136d59ad0958d13142535210855683cd8a9)
+++ src/tests/init_once.c	(revision 85f07136d59ad0958d13142535210855683cd8a9)
@@ -0,0 +1,169 @@
+//
+// Cforall Version 1.0.0 Copyright (C) 2015 University of Waterloo
+//
+// The contents of this file are covered under the licence agreement in the
+// file "LICENCE" distributed with Cforall.
+//
+// init_once.c --
+//
+// Author           : Rob Schluntz
+// Created On       : Tue Jun 14 15:43:35 2016
+// Last Modified By : Rob Schluntz
+// Last Modified On : Tue Jun 14 15:45:03 2016
+// Update Count     : 1
+//
+
+// want to ensure ctor/dtor called at most once per object.
+// whole point of ctor/dtor is that you don't know what's in
+// memory when it's first called, so can't rely on member to
+// determine if this is true. instead, keep an array
+// of addresses that have been constructed and remove the element
+// when it's destructed (and vice-versa)
+
+//*** setup
+extern "C" {
+typedef unsigned long int size_t;
+#define NULL 0
+void * malloc(size_t);
+void free(void *);
+#define assert(cond) if (! (cond)) { printf("Assertion failed: (%s) at %s:%d\n", #cond, __FILE__, __LINE__); abort(); }
+void abort();
+int printf(const char *, ...);
+void *memset(void *s, int c, size_t n);
+}
+
+// dummy type
+struct init_once { int * x; };
+
+// array and operations
+// const int size = 1024;
+#define size 1024
+struct array {
+	init_once * elems[size];
+	int length;
+};
+void remove(array * arr, init_once * x) {
+	for (int i = 0; i < arr->length; i++) {
+		if ( arr->elems[i] == x ) {
+			arr->elems[i] = arr->elems[--arr->length];
+			return;
+		}
+	}
+}
+void insert(array * arr, init_once * x) {
+	assert( arr->length < size );
+	arr->elems[arr->length++] = x;
+}
+int find(array * arr, init_once * x) {
+	for (int i = 0; i < arr->length; i++) {
+		if ( arr->elems[i] == x ) {
+			return i;
+		}
+	}
+	return -1;
+}
+void ?{}(array * arr) {
+	memset(arr->elems, 0, sizeof(arr->elems));
+	arr->length = 0;
+}
+array constructed;
+array destructed;
+
+void ?{}(init_once * x) {
+	assert( find( &constructed, x ) == -1 );
+	remove( &destructed, x );
+	insert( &constructed, x );
+
+	x->x = malloc(sizeof(int));
+}
+
+void ?{}(init_once * x, init_once other) {
+	x{};  // reuse default ctor
+}
+
+void ^?{}(init_once * x) {
+	assert( find( &destructed, x ) == -1 );
+	remove( &constructed, x );
+	insert( &destructed, x );
+
+	free(x->x);
+}
+//*** end setup
+
+// test globals
+init_once x;
+init_once y = x;
+
+int main() {
+	// local variables
+	init_once x;
+	init_once y = x;
+
+	// block scoped variables
+	{
+		init_once x;
+		init_once y = x;
+	}
+
+	// loop variables
+	for (int i = 0 ; i < 10; i++) {
+		init_once x;
+		init_once y = x;
+	}
+	int i = 0;
+	while (i < 10) {
+		init_once x;
+		init_once y = x;
+		i++;
+	}
+
+	// declared in a switch block with a break
+	for (int i = 0; i < 10; i++) {
+		switch (10) {
+			case 1: {
+				init_once x;
+				init_once y = x;
+				(&x) {}; // ensure this doesn't execute
+				break;
+			}
+			case 10: {
+				init_once x;
+				init_once y = x;
+			} // fall through
+			default: {
+				init_once x;
+				init_once y = x;
+				break;
+			}
+		}
+	}
+
+	// labeled break/continue
+	L3: for (int k = 0; k < 10; k++) {
+		init_once x;
+		init_once y = x;
+		L1: for (int i = 0; i < 10; i++){
+			init_once x;
+			init_once y = x;
+			L2: for (int j = 0; j < 10; j++) {
+				init_once x;
+				init_once y = x;
+
+				if (i == 0) continue L1;
+				if (i == 1) continue L2;
+				if (i == 2) break L2;
+				if (i == 3) break L1;
+				if (i == 4) continue L3;
+				if (i == 9) break L3;
+				// if (i == 5) goto ;
+			}
+		}
+	}
+
+
+}
+
+// Local Variables: //
+// tab-width: 4 //
+// compile-command: "cfa init_once.c" //
+// End: //
