Index: src/examples/alloc.c
===================================================================
--- src/examples/alloc.c	(revision 097e2b0772ff883a03cce4090b9e0ba0be47ac18)
+++ src/examples/alloc.c	(revision 097e2b0772ff883a03cce4090b9e0ba0be47ac18)
@@ -0,0 +1,72 @@
+extern "C" {
+    typedef long unsigned int size_t;
+    void *malloc( size_t size );
+    void *calloc( size_t nmemb, size_t size );
+    void *realloc( void *ptr, size_t size );
+    void *memset( void *s, int c, size_t n );
+    void free( void * ptr );
+    int printf( const char *, ... );
+}
+
+forall( type T ) T * malloc( void ) {
+    return (T *)malloc( sizeof(T) );
+}
+forall( type T ) T * calloc( size_t size ) {
+    return (T *)calloc( size, sizeof(T) );
+}
+forall( type T ) T * realloc( T *ptr, size_t n ) {
+    return (T *)(void *)realloc( ptr, sizeof(T) );
+}
+forall( type T ) T * realloc( T *ptr, size_t n, T c ) {
+    return (T *)realloc( ptr, n );
+}
+
+int *foo( int *p, int c );
+int *bar( int *p, int c );
+int *baz( int *p, int c );
+
+int main() {
+    size_t size = 10;
+    int * x = malloc();
+    x = malloc();
+    x = calloc( 10 );					// calloc: array set to 0
+    x = realloc( x, 10 );
+    x = realloc( x, 10, '\0' );
+    x = malloc( 5 );
+    float *fp = malloc() + 1;
+
+    struct St1 { int x; double y; };
+    struct St1 * st1;
+    double *y;
+    x = realloc( st1, 10 );				// SHOULD FAIL!!
+#if 0
+    int *p;
+    p = foo( bar( baz( malloc(), 0 ), 0 ), 0 );
+    free( p );
+
+    struct St2 { int x; double y; };
+    struct St2 * st2;
+
+    y = malloc();
+    st1 = malloc();
+//    st1 = realloc( st2, 10, st1 );
+  
+    *y = 1.0;
+    printf("%f\n", *y);
+
+    st1->x = *x + 1;
+    st1->y = *y *1.5;
+    printf("{ %d, %f }\n", st1->x, st1->y);
+
+    free( y );
+  
+    x = malloc( 10 );
+    for ( int i = 0; i < 10; i += 1 ) {
+	x[i] = i * 10;
+    }
+    for ( int j = 0; j < 10; j += 1 ) {
+	printf( "x[%d] = %d\n", j, x[j] );
+    }
+    free( x );
+#endif
+}
Index: src/examples/asm.c
===================================================================
--- src/examples/asm.c	(revision 097e2b0772ff883a03cce4090b9e0ba0be47ac18)
+++ src/examples/asm.c	(revision 097e2b0772ff883a03cce4090b9e0ba0be47ac18)
@@ -0,0 +1,29 @@
+int fred() {
+    int src;
+    int dst;
+
+    asm volatile ( "mov %1, %0\n\t"
+		   "add $1, %0" : : : );
+
+    asm volatile ( "mov %1, %0\n\t"
+		   "add $1, %0"
+		   : "=" "r" (dst));
+
+    asm volatile ( "mov %1, %0\n\t"
+		   "add $1, %0"
+		   : "=r" (dst)
+		   : "r" (src));
+
+    asm ( "mov %1, %0\n\t"
+	  "add $1, %0"
+	  : "=r" (dst), "=r" (src)
+	  : [src] "r" (dst)
+	  : "r0");
+
+  L1: L2:
+    asm goto ( "frob %%r5, %1; jc %l[L1]; mov (%2), %%r5"
+	       : /* No outputs. */
+	       : "r"(src), "r"(&dst)
+	       : "r5", "memory"
+	       : L1, L2 );
+}
Index: src/examples/constructors.c
===================================================================
--- src/examples/constructors.c	(revision 097e2b0772ff883a03cce4090b9e0ba0be47ac18)
+++ src/examples/constructors.c	(revision 097e2b0772ff883a03cce4090b9e0ba0be47ac18)
@@ -0,0 +1,61 @@
+int fred() {
+    // initialize basic structure
+    struct S {
+	int i, j, k;
+    };
+    void ?{}( S *s ) { s->i = 1, s->k = 2; }		// default constructor
+    void ?{}( S *s, int i, int k ) { s->i = i, s->k = k; } // 2 parameter constructor
+    void ?{}( S *s, S c ) { *s = c; }			// copy constructor
+    void ^?{}( S *s ) { s->i = 0, s->k = 0; }		// default destructor
+    void ^?{}( S *s, int i ) { s->i = i, s->k = i; }	// 1 parameter destructor
+    {
+	S s1;			// default constructor
+	S s2 = { 3, 7 };	// 2 parameter constructor
+	S s3 @= { .k:3, .i:7 };	// 2 parameter C initialization
+	?{}( &s3, 2, 5 );	// explicit 2 parameter constructor
+	^?{}( &s1 );		// explicit call to default destructor
+    } // implicit call to default destructor for s2, explicit call s1, no call for s3
+    S s4 @= {};			// no default construction
+    (&s4){ 2, 5 };		// explicit 2 parameter constructor
+    ^s4{ 3 };			// explicit call to 1 parameter destructor
+
+    // initialize pointer to a basic structure
+
+    void ?{}( S **s ) { *s = malloc(); (*s)->i = 1, (*s)->k = 2; } // default constructor
+    void ?{}( S **s, int i, int k ) { *s = malloc(); (*s)->i = i, (*s)->k = k; } // 2 parameter constructor
+    void ^?{}( S **s ) { (*s)->i = 0, (*s)->k = 0; free( *s ); *s = 0; } // default destructor
+    {
+	S *ps1;			// default constructor
+	S *ps2 = { 3, 7 };	// 2 parameter constructor
+	S *ps3 @= 0;		// C initialization
+	S *ps4 @= {};		// no default construction
+    } // implicit call to default destructor for ps2 and ps1, checks ordering of explicit destructor calls
+
+    ?{}( &ps3, 2, 5 );		// explicit 2 parameter constructor
+    (&ps4){ 2, 5 };		// explicit 2 parameter constructor
+    
+    ^?{}( &ps3 );		// explicit call to default destructor
+    ^ps4{};			// explicit call to default destructor
+
+    // initialize complex structure
+
+    struct T {
+	struct S s;
+    };
+
+    void ?{}( T *t ) {}					// default constructor => implicitly call constructor for field s
+    void ?{}( T *t, int i, int k ) { (&t->s){ i, k }; }	// 2 parameter constructor => explicitly call constructor for field s
+    void ?{}( T *t, S c ) { (&t->s){ c }; }		// 1 parameter constructor => explicitly call copy constructor for field s
+    void ^?{}( T *s, int i ) {}				// destructor => implicitly call destructor for field s
+    {
+	S s;			// default constructor
+	T t1;			// default constructor
+	T t2 = { s };		// 1 parameter constructor
+	^?{}( &t1 );		// explicit call to default destructor => implicit call to t1.s's destructor
+    } // implicit call to default destructor for t2 and implicit call for s;
+    T t3;			// default constructor
+    T t4 @= { { 1, 3 } };	// C initialization
+    (&t4){ 2, 5 };		// explicit 2 parameter constructor
+
+    T *pt = malloc(){ 3, 4 };	// common usage
+} // implicit call to default destructor for t3
Index: src/examples/control_structures.c
===================================================================
--- src/examples/control_structures.c	(revision 721f17ac6221a75230b4b1228917e6a163b53ff6)
+++ src/examples/control_structures.c	(revision 097e2b0772ff883a03cce4090b9e0ba0be47ac18)
@@ -10,6 +10,6 @@
 // Created On       : Wed May 27 17:56:53 2015
 // Last Modified By : Peter A. Buhr
-// Last Modified On : Thu Jun  4 14:02:50 2015
-// Update Count     : 24
+// Last Modified On : Fri Sep 18 08:12:17 2015
+// Update Count     : 28
 //
 
@@ -26,6 +26,6 @@
 						break L3;
 						break L4;
-						//continue L1;					// labelled continue - should be an error 
-						//continue L2;					// should be an error
+						//continue L1;					// error: not enclosing loop
+						//continue L2;					// error: not enclosing loop
 						continue L3;
 						continue L4;
Index: src/examples/nestedfunc.c
===================================================================
--- src/examples/nestedfunc.c	(revision 097e2b0772ff883a03cce4090b9e0ba0be47ac18)
+++ src/examples/nestedfunc.c	(revision 097e2b0772ff883a03cce4090b9e0ba0be47ac18)
@@ -0,0 +1,34 @@
+extern "C" {
+    int printf( const char *, ... );
+}
+
+// Insertion sort on a, of length n
+forall( type T | { int ?<?(T, T); } )
+void sort( T *a, unsigned long n ) {
+    if ( n <= 1 ) return;
+	
+    for ( unsigned long i = 1; i < n; i += 1 ) {
+	T x; x = a[i];
+	unsigned long j = i;
+	for ( j; j > 0 && x < a[j-1]; j -= 1 ) {
+	    a[j] = a[j - 1];
+	} // for
+	a[j] = x;
+    } // for
+}
+
+int main(void) {
+    const int size = 4;
+    int a[4] = { 0, 3, -2, 100 };
+    printf( "a:[%d %d %d %d]\n", a[0], a[1], a[2], a[3] );
+	
+    sort( a, size );
+    printf( "a:[%d %d %d %d]\n", a[0], a[1], a[2], a[3] );
+    {
+	// int ?<?(int, int) = ?>?;
+	int ?<?( int a, int b ) { return a > b; }
+	sort( a, size );
+    }
+    printf( "a:[%d %d %d %d]\n", a[0], a[1], a[2], a[3] );
+}
+
Index: src/examples/poly-bench.c
===================================================================
--- src/examples/poly-bench.c	(revision 097e2b0772ff883a03cce4090b9e0ba0be47ac18)
+++ src/examples/poly-bench.c	(revision 097e2b0772ff883a03cce4090b9e0ba0be47ac18)
@@ -0,0 +1,207 @@
+//
+// 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.
+//
+// poly-bench.cc -- 
+//
+// Author           : Aaron Moss
+// Created On       : Sat May 16 07:26:30 2015
+// Last Modified By : Peter A. Buhr
+// Last Modified On : Wed May 27 18:25:19 2015
+// Update Count     : 5
+//
+
+extern "C" {
+#include <stdio.h>
+//#include "my_time.h"
+}
+
+#define N 200000000
+
+struct ipoint {
+	int x;
+	int y;
+};
+
+struct ipoint ?+?(struct ipoint a, struct ipoint b) {
+	struct ipoint r;
+	r.x = a.x + b.x;
+	r.y = a.y + b.y;
+	return r;
+}
+
+struct ipoint ?-?(struct ipoint a, struct ipoint b) {
+	struct ipoint r;
+	r.x = a.x - b.x;
+	r.y = a.y - b.y;
+	return r;
+}
+
+struct ipoint ?*?(struct ipoint a, struct ipoint b) {
+	struct ipoint r;
+	r.x = a.x * b.x;
+	r.y = a.y * b.y;
+	return r;
+}
+
+struct dpoint {
+	double x;
+	double y;
+};
+
+struct dpoint ?+?(struct dpoint a, struct dpoint b) {
+	struct dpoint r;
+	r.x = a.x + b.x;
+	r.y = a.y + b.y;
+	return r;
+}
+
+struct dpoint ?-?(struct dpoint a, struct dpoint b) {
+	struct dpoint r;
+	r.x = a.x - b.x;
+	r.y = a.y - b.y;
+	return r;
+}
+
+struct dpoint ?*?(struct dpoint a, struct dpoint b) {
+	struct dpoint r;
+	r.x = a.x * b.x;
+	r.y = a.y * b.y;
+	return r;
+}
+
+int a2b2_mono_int(int a, int b) {
+	return (a - b)*(a + b);
+}
+
+double a2b2_mono_double(double a, double b) {
+	return (a - b)*(a + b);
+}
+
+struct ipoint a2b2_mono_ipoint(struct ipoint a, struct ipoint b) {
+	return (a - b)*(a + b);
+}
+
+struct dpoint a2b2_mono_dpoint(struct dpoint a, struct dpoint b) {
+	return (a - b)*(a + b);
+}
+
+forall(type T | { T ?+?(T,T); T ?-?(T,T); T ?*?(T,T); })
+T a2b2_poly(T a, T b) {
+	return (a - b)*(a + b);
+}
+
+typedef int clock_t;
+long ms_between(clock_t start, clock_t end) {
+//	return (end - start) / (CLOCKS_PER_SEC / 1000);
+	return 0;
+}
+int clock() { return 3; }
+
+int main(int argc, char** argv) {
+	clock_t start, end;
+	int i;
+	
+	int a, b;
+	double c, d;
+	struct ipoint p, q;
+	struct dpoint r, s;
+	
+	printf("\n## a^2-b^2 ##\n");
+	
+	a = 5, b = 3;
+	start = clock();
+	for (i = 0; i < N/2; ++i) {
+		a = a2b2_mono_int(a, b);
+		b = a2b2_mono_int(b, a);
+	}
+	end = clock();
+	printf("mono_int:   %7ld  [%d,%d]\n", ms_between(start, end), a, b);
+	
+	a = 5, b = 3;
+	start = clock();
+	for (i = 0; i < N/2; ++i) {
+		a = a2b2_poly(a, b);
+		b = a2b2_poly(b, a);
+	}
+	end = clock();
+	printf("poly_int:   %7ld  [%d,%d]\n", ms_between(start, end), a, b);
+	
+/*	{
+	a = 5, b = 3;
+	// below doesn't actually work; a2b2_poly isn't actually assigned, just declared
+	* [int] (int, int) a2b2_poly = a2b2_mono_int;
+	start = clock();
+	for (i = 0; i < N/2; ++i) {
+//			printf("\t[%d,%d]\n", a, b);
+a = a2b2_poly(a, b);
+//			printf("\t[%d,%d]\n", a, b);
+b = a2b2_poly(b, a);
+}
+end = clock();
+printf("spec_int:   %7ld  [%d,%d]\n", ms_between(start, end), a, b);
+}
+*/	
+	c = 5.0, d = 3.0;
+	start = clock();
+	for (i = 0; i < N/2; ++i) {
+		c = a2b2_mono_double(c, d);
+		d = a2b2_mono_double(d, c);
+	}
+	end = clock();
+	printf("mono_double:%7ld  [%f,%f]\n", ms_between(start, end), c, d);
+		
+	c = 5.0, d = 3.0;
+	start = clock();
+	for (i = 0; i < N/2; ++i) {
+		c = a2b2_poly(c, d);
+		d = a2b2_poly(d, c);
+	}
+	end = clock();
+	printf("poly_double:%7ld  [%f,%f]\n", ms_between(start, end), c, d);
+	
+	p.x = 5, p.y = 5, q.x = 3, q.y = 3;
+	start = clock();
+	for (i = 0; i < N/2; ++i) {
+		p = a2b2_mono_ipoint(p, q);
+		q = a2b2_mono_ipoint(q, p);
+	}
+	end = clock();
+	printf("mono_ipoint:%7ld  [(%d,%d),(%d,%d)]\n", ms_between(start, end), p.x, p.y, q.x, q.y);
+		
+	p.x = 5, p.y = 5, q.x = 3, q.y = 3;
+	start = clock();
+	for (i = 0; i < N/2; ++i) {
+		p = a2b2_poly(p, q);
+		q = a2b2_poly(q, p);
+	}
+	end = clock();
+	printf("poly_ipoint:%7ld  [(%d,%d),(%d,%d)]\n", ms_between(start, end), p.x, p.y, q.x, q.y);
+	
+	r.x = 5.0, r.y = 5.0, s.x = 3.0, s.y = 3.0;
+	start = clock();
+	for (i = 0; i < N/2; ++i) {
+		r = a2b2_mono_dpoint(r, s);
+		s = a2b2_mono_dpoint(s, r);
+	}
+	end = clock();
+	printf("mono_dpoint:%7ld  [(%f,%f),(%f,%f)]\n", ms_between(start, end), r.x, r.y, s.x, s.y);
+		
+	r.x = 5.0, r.y = 5.0, s.x = 3.0, s.y = 3.0;
+	start = clock();
+	for (i = 0; i < N/2; ++i) {
+		r = a2b2_poly(r, s);
+		s = a2b2_poly(s, r);
+	}
+	end = clock();
+	printf("poly_dpoint:%7ld  [(%f,%f),(%f,%f)]\n", ms_between(start, end), r.x, r.y, s.x, s.y);
+
+	return 0;
+}
+
+// Local Variables: //
+// tab-width: 4 //
+// compile-command: "cfa poly-bench.c" //
+// End: //
Index: src/examples/sum.c
===================================================================
--- src/examples/sum.c	(revision 721f17ac6221a75230b4b1228917e6a163b53ff6)
+++ src/examples/sum.c	(revision 097e2b0772ff883a03cce4090b9e0ba0be47ac18)
@@ -7,28 +7,29 @@
 // sum.c -- 
 //
-// Author           : Richard C. Bilson
+// Author           : Peter A. Buhr
 // Created On       : Wed May 27 17:56:53 2015
 // Last Modified By : Peter A. Buhr
-// Last Modified On : Mon Jun  1 20:46:35 2015
-// Update Count     : 18
+// Last Modified On : Mon Sep 28 15:09:55 2015
+// Update Count     : 118
 //
 
 extern "C" {
-	int printf( const char *, ... );
+	int printf( char *, ... );
 }
+#include "fstream.h"
 
 context sumable( type T ) {
 	const T 0;
 	T ?+?( T, T );
+	T ?+=?( T *, T );
+	T ++?( T * );
 	T ?++( T * );
-	T ?+=?( T *, T );
 };
 
 forall( type T | sumable( T ) )
-T sum( int n, T a[] ) {
-	T total;											// instantiate T, select 0
-	total = 0;
-	for ( int i = 0; i < n; i += 1 )
-		total = total + a[i];							// select +
+T sum( unsigned int n, T a[] ) {
+	T total = 0;										// instantiate T, select 0
+	for ( unsigned int i = 0; i < n; i += 1 )
+		total += a[i];									// select +
 	return total;
 }
@@ -36,37 +37,54 @@
 // Required to satisfy sumable as char does not have addition.
 const char 0;
-char ?+?( char op1, char op2 ) { return op1 + op2; }
-char ?++( char *op ) { return *op + 1; }
-
-const double 0; // TEMPORARY, incorrect use of int 0
+char ?+?( char op1, char op2 ) { return (int)op1 + op2; } // cast forces integer addition or recursion
+char ++?( char *op ) { *op += 1; return *op; }
+char ?++( char *op ) { char temp = *op; *op += 1; return temp; }
 
 int main() {
 	const int low = 5, High = 15, size = High - low;
-	int si = 0, ai[size];
+
+	ofstream *sout = ofstream_stdout();
+
+	char s = 0, a[size];
+	char v = low;
+	for ( int i = 0; i < size; i += 1, v += 1 ) {
+		s += v;
+		a[i] = v;
+	}
+	sout << "sum from " << low << " to " << High << " is "
+		 << (int)sum( size, a ) << ", check " << (int)s << "\n";
+
+	int s = 0, a[size];
 	int v = low;
 	for ( int i = 0; i < size; i += 1, v += 1 ) {
-		si += v;
-		ai[i] = v;
+		s += (int)v;
+		a[i] = (int)v;
 	}
-	printf( "sum from %d to %d is %d, check %d\n",
-			low, High, sum( size, ai ), si );
+	sout << "sum from " << low << " to " << High << " is "
+		 << sum( size, (int *)a ) << ", check " << (int)s << "\n";
 
-//	char ci[size];
-//	char c = sum( size, ci );
-//	float fi[size];
-//	float f = sum( size, fi );
-
-	double sd = 0.0, ad[size];
+	double s = 0.0, a[size];
 	double v = low / 10.0;
 	for ( int i = 0; i < size; i += 1, v += 0.1 ) {
-		sd += v;
-		ad[i] = v;
+		s += (double)v;
+		a[i] = (double)v;
 	}
-	printf( "sum from %g to %g is %g, check %g\n",
-			low / 10.0, High / 10.0, sum( size, ad ), sd );
+	printf( "%g\n", sum( size, (double *)a ) );
+//	sout << "sum from " << low / 10.0 << " to " << High / 10.0 << " is "
+//		 << sum( size, (double *)a ) << ", check " << (double)s << "\n";
+
+	float s = 0.0, a[size];
+	float v = low / 10.0;
+	for ( int i = 0; i < size; i += 1, v += 0.1f ) {
+		s += (float)v;
+		a[i] = (float)v;
+	}
+	printf( "%g\n", sum( size, (float *)a ) );
+//	sout << "sum from " << low / 10.0 << " to " << High / 10.0 << " is "
+//		 << sum( size, (float *)a ) << ", check " << (float)s << "\n";
 }
 
 // Local Variables: //
 // tab-width: 4 //
-// compile-command: "cfa sum.c" //
+// compile-command: "cfa sum.c fstream.o iostream.o" //
 // End: //
