- Timestamp:
- Jun 14, 2016, 1:23:18 PM (8 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- 545ef59, c738ca4, ee51534
- Parents:
- 6cbc25a (diff), c8c03683 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - Location:
- src/tests
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
src/tests/Array.c
r6cbc25a r7ff30d07 1 1 //Testing array declarations 2 2 int a1[]; 3 int a2[*];4 double a4[3.0];3 //int a2[*]; 4 //double a4[3.0]; 5 5 6 6 int m1[][3]; 7 int m2[*][*];7 //int m2[*][*]; 8 8 int m4[3][3]; 9 9 … … 11 11 12 12 int fred() { 13 int a1[];14 int a2[*];13 // int a1[]; 14 // int a2[*]; 15 15 int a4[3]; 16 16 int T[3]; -
src/tests/Forall.c
r6cbc25a r7ff30d07 7 7 8 8 void g1() { 9 forall( type T ) T f( T );9 forall( otype T ) T f( T ); 10 10 void f( int ); 11 11 void h( void (*p)(void) ); … … 24 24 25 25 void g2() { 26 forall( type T ) void f( T, T );27 forall( type T,type U ) void f( T, U );26 forall( otype T ) void f( T, T ); 27 forall( otype T, otype U ) void f( T, U ); 28 28 29 29 int x; … … 37 37 } 38 38 39 typedef forall ( type T ) int (*f)( int );39 typedef forall ( otype T ) int (*f)( int ); 40 40 41 forall( type T )41 forall( otype T ) 42 42 void swap( T left, T right ) { 43 43 T temp = left; … … 46 46 } 47 47 48 context sumable( type T ) {48 context sumable( otype T ) { 49 49 const T 0; 50 50 T ?+?(T, T); … … 53 53 }; 54 54 55 type T1 | { const T1 0; T1 ?+?(T1, T1); T1 ?++(T1); [T1] ?+=?(T1,T1); },56 T2( type P1,type P2 ),55 otype T1 | { const T1 0; T1 ?+?(T1, T1); T1 ?++(T1); [T1] ?+=?(T1,T1); }, 56 T2(otype P1, otype P2 ), 57 57 T3 | sumable(T3); 58 58 59 type T2(type P1,type P2) | sumable(T2(P1,P2)) = struct { P1 i; P2 j; };59 otype T2(otype P1, otype P2) | sumable(T2(P1,P2)) = struct { P1 i; P2 j; }; 60 60 61 61 T2(int, int) w1; 62 62 typedef T2(int, int) w2; 63 63 w2 g2; 64 type w3 = T2(int, int);64 otype w3 = T2(int, int); 65 65 w3 g3; 66 66 67 forall( type T | sumable( T ) )67 forall( otype T | sumable( T ) ) 68 68 T sum( int n, T a[] ) { 69 69 T total = 0; … … 74 74 } 75 75 76 forall( type T | { const T 0; T ?+?(T, T); T ?++(T); [T] ?+=?(T,T); } )76 forall( otype T | { const T 0; T ?+?(T, T); T ?++(T); [T] ?+=?(T,T); } ) 77 77 T twice( T t ) { 78 78 return t + t; 79 79 } 80 80 81 forall( type T | { const T 0; int ?!=?(T, T); int ?<?(T, T); } )81 forall( otype T | { const T 0; int ?!=?(T, T); int ?<?(T, T); } ) 82 82 T min( T t1, T t2 ) { 83 83 return t1 < t2 ? t1 : t2; -
src/tests/Functions.c
r6cbc25a r7ff30d07 28 28 int ((*f12())[])[3] {} 29 29 30 // "implicit int" type specifier (not ANSI)30 // "implicit int" otype specifier (not ANSI) 31 31 32 32 fII1( int i ) {} -
src/tests/GccExtensions.c
r6cbc25a r7ff30d07 19 19 __signed s2; 20 20 21 __ typeof(s1) t1;22 __ typeof__(s1) t2;21 __otypeof(s1) t1; 22 __otypeof__(s1) t2; 23 23 24 24 __volatile int v1; -
src/tests/Scope.c
r6cbc25a r7ff30d07 3 3 typedef float t; 4 4 y z; 5 type u = struct { int a; double b; };5 otype u = struct { int a; double b; }; 6 6 int f( int y ); 7 7 y q; 8 8 9 9 y w( y y, u v ) { 10 type x | { x t(u); };10 otype x | { x t(u); }; 11 11 u u = y; 12 12 x z = t(u); … … 15 15 y p; 16 16 17 context has_u( type z ) {17 context has_u( otype z ) { 18 18 z u(z); 19 19 }; 20 20 21 forall( type t | has_u( t ) )21 forall( otype t | has_u( t ) ) 22 22 y q( t the_t ) { 23 23 t y = u( the_t ); -
src/tests/Subrange.c
r6cbc25a r7ff30d07 1 // A small context defining the notion of an ordered type. (The standard1 // A small context defining the notion of an ordered otype. (The standard 2 2 // library should probably contain a context for this purpose.) 3 context ordered( type T) {3 context ordered(otype T) { 4 4 int ?<?(T, T), ?<=?(T, T); 5 5 }; 6 6 7 // A subrange type resembling an Ada subtype with a basetype and a range7 // A subrange otype resembling an Ada subotype with a base otype and a range 8 8 // constraint. 9 type subrange(type base_t | ordered(base_t), base_t low = 0, base_t high = 8) = base_t;9 otype subrange(otype base_t | ordered(base_t), base_t low = 0, base_t high = 8) = base_t; 10 10 11 // Note that subrange() can be applied to floating-point and pointer types, not12 // just integral types.13 // This requires a " type generator" extension to Cforall. Type generators14 // must accept type and non-type parameters, which is beyond what we discussed11 // Note that subrange() can be applied to floating-point and pointer otypes, not 12 // just integral otypes. 13 // This requires a "otype generator" extension to Cforall. Type generators 14 // must accept otype and non-otype parameters, which is beyond what we discussed 15 15 // previously. Type parameters must be usable in the declaration of 16 16 // subsequent parameters: parameter T is used to declare parameters "low" … … 22 22 subrange(int, 0, (rand() & 0xF) ) foo; 23 23 24 // What sorts of expressions can be used as arguments of type generators? Is24 // What sorts of expressions can be used as arguments of otype generators? Is 25 25 // "subrange(int, 0, rand() & 0xF)" legal? Probably. The nearest C equivalent 26 26 // to the "low" and "high" arguments is the array size in a variable-length … … 28 28 29 29 // Convenient access to subrange bounds, for instance for iteration: 30 forall ( type T, T low, T high)30 forall (otype T, T low, T high) 31 31 T lbound( subrange(T, low, high) v) { 32 32 return low; 33 33 } 34 34 35 forall ( type T, T low, T high)35 forall (otype T, T low, T high) 36 36 T hbound( subrange(T, low, high) v) { 37 37 return high; … … 41 41 unsigned lday = lbound(day_of_month); 42 42 43 // Assignment from the base type, with bounds checking. I'll ignore the issue43 // Assignment from the base otype, with bounds checking. I'll ignore the issue 44 44 // of exception handling here. Inlining allows the compiler to eliminate 45 45 // bounds checks. 46 forall ( type T | ordered(T), T low, T high)46 forall (otype T | ordered(T), T low, T high) 47 47 inline subrange(T, low, high) ?=?(subrange(T, low, high)* target, T source) { 48 48 if (low <= source && source <= high) *((T*)target) = source; … … 51 51 } 52 52 53 // Assignment between subranges with a common base type. The bounds check53 // Assignment between subranges with a common base otype. The bounds check 54 54 // compares range bounds so that the compiler can optimize checks away when the 55 55 // ranges are known to overlap. 56 forall ( type T | ordered(T), T t_low, T t_high, T s_low, T s_high)56 forall (otype T | ordered(T), T t_low, T t_high, T s_low, T s_high) 57 57 inline subrange(T, t_low, t_high) ?=?(subrange(T, t_low, t_high)* target, 58 58 subrange(T, s_low, s_high) source) { -
src/tests/TypeGenerator.c
r6cbc25a r7ff30d07 1 context addable( type T ) {1 context addable( otype T ) { 2 2 T ?+?( T,T ); 3 3 T ?=?( T*, T); 4 4 }; 5 5 6 type List1(type T | addable( T ) ) = struct { T data; List1( T ) *next; } *;6 otype List1( otype T | addable( T ) ) = struct { T data; List1( T ) *next; } *; 7 7 typedef List1( int ) ListOfIntegers; 8 8 //List1( int ) li; … … 11 11 [int] h( * List1( int ) p ); // new declaration syntax 12 12 13 struct( type T ) S2 { T i; }; // actual definition13 struct( otype T ) S2 { T i; }; // actual definition 14 14 struct( int ) S3 v1, *p; // expansion and instantiation 15 struct( type T )( int ) S24 { T i; } v2; // actual definition, expansion and instantiation16 struct( type T )( int ) { T i; } v2; // anonymous actual definition, expansion and instantiation15 struct( otype T )( int ) S24 { T i; } v2; // actual definition, expansion and instantiation 16 struct( otype T )( int ) { T i; } v2; // anonymous actual definition, expansion and instantiation 17 17 18 struct( type T | addable( T ) ) node { T data; struct( T ) node *next; };19 type List(type T ) = struct( T ) node *;18 struct( otype T | addable( T ) ) node { T data; struct( T ) node *next; }; 19 otype List( otype T ) = struct( T ) node *; 20 20 List( int ) my_list; 21 21 22 type Complex | addable( Complex );22 otype Complex | addable( Complex ); 23 23 24 24 int main() { -
src/tests/Typedef.c
r6cbc25a r7ff30d07 18 18 a c; 19 19 20 typedef typeof(3) x, y; // GCC20 typedef otypeof(3) x, y; // GCC 21 21 22 22 x p; … … 24 24 25 25 int main() { 26 typedef typeof(3) z, p;26 typedef otypeof(3) z, p; 27 27 z w; 28 28 p x; -
src/tests/Typeof.c
r6cbc25a r7ff30d07 1 1 int main() { 2 2 int *v1; 3 typeof(v1) v2;4 typeof(*v1) v3[4];3 otypeof(v1) v2; 4 otypeof(*v1) v3[4]; 5 5 char *v4[4]; 6 typeof(typeof(char *)[4]) v5;7 typeof (int *) v6;8 typeof( int ( int, int p ) ) *v7;9 typeof( [int] ( int, int p ) ) *v8;6 otypeof(otypeof(char *)[4]) v5; 7 otypeof (int *) v6; 8 otypeof( int ( int, int p ) ) *v7; 9 otypeof( [int] ( int, int p ) ) *v8; 10 10 } -
src/tests/io.c
r6cbc25a r7ff30d07 11 11 // Created On : Wed Mar 2 16:56:02 2016 12 12 // Last Modified By : Peter A. Buhr 13 // Last Modified On : Thu May 26 10:06:00201614 // Update Count : 2813 // Last Modified On : Wed Jun 8 22:52:04 2016 14 // Update Count : 30 15 15 // 16 16 … … 34 34 long double _Complex ldc; 35 35 char s1[10], s2[10]; 36 37 int x = 3, y = 5, z = 7; 38 sout | x * 3 | y + 1 | z << 2 | x == y | (x | y) | (x || y) | (x > z ? 1 : 2) | endl; 39 sout | 1 | 2 | 3 | endl; 40 sout | '1' | '2' | '3' | endl; 41 sout | 1 | "" | 2 | "" | 3 | endl; 42 sout | endl; 36 43 37 44 ifstream in; // create / open file
Note: See TracChangeset
for help on using the changeset viewer.