Changeset fd54fef for tests/forall.cfa
 Timestamp:
 Jan 19, 2021, 8:44:29 PM (2 years ago)
 Branches:
 ADT, armeh, enum, forallpointerdecay, jacob/cs343translation, master, newastuniqueexpr, pthreademulation, qualifiedEnum
 Children:
 dafbde8
 Parents:
 2f47ea4
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

tests/forall.cfa
r2f47ea4 rfd54fef 15 15 16 16 void g1() { 17 forall( otypeT ) T f( T ) {};17 forall( T ) T f( T ) {}; 18 18 void f( int ) {}; 19 19 void h( void (*p)(void) ) {}; … … 32 32 33 33 void g2() { 34 forall( otypeT ) void f( T, T ) {}35 forall( otype T, otypeU ) void f( T, U ) {}34 forall( T ) void f( T, T ) {} 35 forall( T, U ) void f( T, U ) {} 36 36 37 37 int x; … … 45 45 } 46 46 47 typedef forall ( otypeT ) int (* f)( int );48 49 forall( otypeT )47 typedef forall ( T ) int (* f)( int ); 48 49 forall( T ) 50 50 void swap( T left, T right ) { 51 51 T temp = left; … … 54 54 } 55 55 56 trait sumable( otypeT ) {56 trait sumable( T ) { 57 57 void ?{}( T &, zero_t ); // 0 literal constructor 58 58 T ?+?( T, T ); // assortment of additions … … 62 62 }; // sumable 63 63 64 forall( otypeT  sumable( T ) ) // use trait64 forall( T  sumable( T ) ) // use trait 65 65 T sum( size_t size, T a[] ) { 66 66 T total = 0; // initialize by 0 constructor … … 70 70 } // sum 71 71 72 forall( otypeT  { T ?+?( T, T ); T ?++( T & ); [T] ?+=?( T &,T ); } )72 forall( T  { T ?+?( T, T ); T ?++( T & ); [T] ?+=?( T &,T ); } ) 73 73 T twice( T t ) { 74 74 return t + t; 75 75 } 76 76 77 forall( otypeT  { int ?<?(T, T); } )77 forall( T  { int ?<?(T, T); } ) 78 78 T min( T t1, T t2 ) { 79 79 return t1 < t2 ? t1 : t2; … … 91 91 92 92 // Multiple forall 93 forall( otype T ) forall( otypeS ) struct { int i; };94 forall( otype T ) struct { int i; } forall( otypeS );95 struct { int i; } forall( otype T ) forall( otypeS );96 forall( otype W ) struct { int i; } forall( otype T ) forall( otypeS );93 forall( T ) forall( S ) struct { int i; }; 94 forall( T ) struct { int i; } forall( S ); 95 struct { int i; } forall( T ) forall( S ); 96 forall( W ) struct { int i; } forall( T ) forall( S ); 97 97 98 98 // Distribution 99 99 struct P { int i; }; 100 forall( otypeT ) struct Q { T i; };101 forall( otypeT ) struct { int i; };100 forall( T ) struct Q { T i; }; 101 forall( T ) struct { int i; }; 102 102 struct KK { int i; }; 103 103 inline static { 104 104 void RT1() {} 105 105 } 106 forall( otypeT ) {106 forall( T ) { 107 107 T RT2( T ) { 108 108 typedef int TD1; 109 109 struct S1 { T t; }; 110 110 } 111 forall( otypeX ) {111 forall( X ) { 112 112 typedef int TD2; 113 113 struct S2 {}; … … 117 117 } 118 118 extern "C" { 119 forall( otypeW ) {119 forall( W ) { 120 120 W RT3( W ) {} 121 121 struct S3 {}; … … 123 123 } 124 124 void RT4() { 125 forall( otypeW ) struct S4 {};125 forall( W ) struct S4 {}; 126 126 typedef int TD3; 127 127 } … … 147 147 148 148 static inline { 149 forall( otypeT ) {149 forall( T ) { 150 150 int RT6( T p ); 151 151 } 152 forall( otype T, otypeU ) {152 forall( T, U ) { 153 153 int RT7( T, U ); 154 154 } 155 155 } 156 static forall( otypeT ) {156 static forall( T ) { 157 157 int RT8( T ); 158 158 } 159 forall( otypeT ) inline static {159 forall( T ) inline static { 160 160 int RT9( T ) { T t; return 3; } 161 161 } 162 162 163 forall( otypeT  { T ?+?( T, T ); } ) {164 forall( otypeS  { T ?+?( T, S ); } ) {165 forall( otypeW ) T bar( T t, S s ) { return t + s; }166 forall( otypeW  { W ?+?( T, W ); } ) W baz( T t, S s, W w ) { return t + s + w; }163 forall( T  { T ?+?( T, T ); } ) { 164 forall( S  { T ?+?( T, S ); } ) { 165 forall( W ) T bar( T t, S s ) { return t + s; } 166 forall( W  { W ?+?( T, W ); } ) W baz( T t, S s, W w ) { return t + s + w; } 167 167 struct W { T t; } (int,int) ww; 168 168 struct P pp; … … 170 170 } 171 171 172 forall( otype T  { T ?+?( T, T ); } ) forall( otypeS  { T ?+?( T, S ); } )172 forall( T  { T ?+?( T, T ); } ) forall( S  { T ?+?( T, S ); } ) 173 173 struct XW { T t; }; 174 174 XW(int,int) xww; 175 175 176 forall( otypeT ) struct S { T t; } (int) x, y, z;177 forall( otypeT ) struct { T t; } (int) a, b, c;178 179 forall( otype T ) static forall( otypeS ) {180 forall( otypeX ) struct U {176 forall( T ) struct S { T t; } (int) x, y, z; 177 forall( T ) struct { T t; } (int) a, b, c; 178 179 forall( T ) static forall( S ) { 180 forall( X ) struct U { 181 181 T x; 182 182 }; 183 183 } 184 184 185 forall( otypeT ) {185 forall( T ) { 186 186 extern "C" { 187 187 struct SS { T t; };
Note: See TracChangeset
for help on using the changeset viewer.