Changeset cdbab55 for examples/Tuple.c
- Timestamp:
- Aug 21, 2018, 2:24:29 PM (8 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, stuck-waitfor-destruct
- Children:
- 2a6292d
- Parents:
- 2b79a70 (diff), efa8b6af (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. - File:
-
- 1 moved
-
examples/Tuple.c (moved) (moved from src/examples/Tuple.c ) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
examples/Tuple.c
r2b79a70 rcdbab55 1 1 int f( int, int ); 2 2 int g( int, int, int ); 3 static [ int, int *, * int, int ] h( int a, int b, * int c, [] char d ); 3 static 4 [ int, int *, * int, int ] h( int a, int b, * int c, [] char d ); 4 5 5 6 struct inner { … … 14 15 15 16 const volatile [ int, int ] t1; 16 static const [ int, constint ] t2;17 static const [ int, int ] t2; 17 18 const static [ int, const int ] t3; 18 19 … … 21 22 22 23 [ short x, unsigned y ] f1( int w ) { 23 [ y, x ] = [ x, y ] = [ w, 23 ];24 // return [ y, x ] = [ x, y ] = [ w, 23 ]; 24 25 } 25 26 26 27 [ [ int, char, long, int ] r ] g1() { 27 short x, p;28 short int x, p; 28 29 unsigned int y; 29 30 [ int, int ] z; 30 31 31 [ x, y, z ] = [ p, f( 17 ), 3 ];32 [ x, y, z ] = ([short, unsigned int, [int, int]])([ p, f( 17 ), 3 ]);32 [ x, y, z ] = [ p, f( 17, 18 ), 4, 3 ]; 33 // [ x, y, z ] = ([short, unsigned int, [int, int]])([ p, f( 17, 18 ), 4, 3 ]); 33 34 r = [ x, y, z ]; 34 35 } … … 36 37 [ int rc ] main( int argc, ** char argv ) { 37 38 int a, b, c, d; 38 struct outer t = { .[ f1,f4 ] : [ 1,7.0 ] };39 // struct outer t = { .[ f1, f4 ] : [ 1, 7.0 ] }; 39 40 f( [ 3,5 ] ); 40 41 g( [ 3,5 ], 3 ); … … 42 43 g( t1, 3 ); 43 44 44 [ , , , ]; /* empty tuple */45 // [ , , , ]; /* empty tuple */ 45 46 [ 3, 5 ]; 46 47 [ a, b ] = 3; 47 [ a, b ] = [ 4.6 ]; 48 // [ a, b ] = [ 4.6 ]; 49 [ a, b ] = 4.6; 48 50 [ a, b ] = [ c, d ] = [ 3, 5 ]; 49 [ a, b, [ c ] ] = [ 2,[ a, b ] ]; 51 // [ a, b, [ c ] ] = [ 2, [ a, b ] ]; 52 [ a, b, c ] = [ 2, [ a, b ] ]; 50 53 [ a, b ] = 3 > 4 ? [ b, 6 ] : [ 7, 8 ]; 51 54 … … 56 59 [ a, b ] = t1 = [ c, d ]; 57 60 [ a, b ] = t1 = t2 = [ c, d ]; 58 t1 = [ 3, 4 ] = [ 3, 4 ] = t1 = [ 3, 4 ];61 // t1 = [ 3, 4 ] = [ 3, 4 ] = t1 = [ 3, 4 ]; 59 62 60 63 s.[ f1, i.[ f2, f3 ], f4 ] = [ 11, 12, 13, 3.14159 ]; 61 s.[ f1, i.[ f2, f3 ], f4 ] = h( 3, 3,0, "abc" );62 [ a, , b, ] = h( 3, 3, 0, "abc" ); /* ignore some results */63 sp->[ f4, f1 ] = sp->[ f1, f4 ];64 // s.[ f1, i.[ f2, f3 ], f4 ] = h( 3, 3, (* int)0, "abc" ); 65 // [ a, , b, ] = h( 3, 3, 0, "abc" ); /* ignore some results */ 66 sp->[ f4, f1 ] = sp->[ f1, f4 ]; 64 67 printf( "expecting 3, 17, 23, 4; got %d, %d, %d, %d\n", s.[ f4, i.[ f3, f2 ], f1 ] ); 65 68 rc = 0;
Note:
See TracChangeset
for help on using the changeset viewer.