Changeset 85a3806
- Timestamp:
- Jun 29, 2023, 12:12:35 PM (17 months ago)
- Branches:
- master
- Children:
- 6587f9d
- Parents:
- 7d25f44
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
tests/designations.cfa
r7d25f44 r85a3806 10 10 // Created On : Thu Jun 29 15:26:36 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Mar 28 22:41:55 2022 13 // Update Count : 15 14 // 12 // Last Modified On : Thu Jun 29 11:31:21 2023 13 // Update Count : 28 14 // 15 16 #include <fstream.hfa> 15 17 16 18 // Note: this test case has been crafted so that it compiles with both cfa and with gcc without any modifications. … … 21 23 #define AT @ 22 24 #else 23 int printf( const char *, ...);24 25 #define _ = 25 26 #define AT … … 28 29 const int indentAmt = 2; 29 30 void indent( int level ) { 30 for ( int i = 0; i < level; ++i ) { 31 printf( " " ); 32 } 31 sout | wd( level, "" ) | nonl; 33 32 } 34 33 … … 40 39 void printA( struct A a, int level ) { 41 40 indent( level ); 42 printf( "(A){ %d %d %p }\n", a.x, a.y, a.ptr );41 sout | "(A){ " | a.x | a.y | a.ptr | " }"; 43 42 } 44 43 … … 49 48 void printB( struct B b, int level ) { 50 49 indent( level ); 51 printf( "(B){\n" );50 sout | "(B){"; 52 51 printA( b.a0, level+indentAmt ); 53 52 printA( b.a1, level+indentAmt ); 54 53 indent( level ); 55 printf( "}\n" );54 sout | "}"; 56 55 } 57 56 … … 63 62 void printC( struct C c, int level ) { 64 63 indent( level ); 65 printf( "(C){\n" );64 sout | "(C){"; 66 65 indent( level+indentAmt ); 67 printf( "(int[]{ %d %d %d }\n", c.arr[0], c.arr[1], c.arr[2]);66 sout | "(int[]{ " | c.arr[0] | c.arr[1] | c.arr[2] | " }"; 68 67 printB( c.b, level+indentAmt ); 69 68 indent( level ); 70 printf( "}\n" );69 sout | "}"; 71 70 } 72 71 … … 79 78 void printD( struct D d, int level ) { 80 79 indent( level); 81 printf( "(D ){ %d }\n", d.x );80 sout | "(D){ " | d.x | "}"; 82 81 } 83 82 … … 92 91 93 92 struct Fred { 94 95 96 97 struct Jane {98 99 } j;100 double i;101 93 double i[3]; 94 int j; 95 struct Mary { 96 struct Jane { 97 double j; 98 } j; 99 double i; 100 } m; 102 101 }; 103 102 struct Fred s1 AT= { .m.j _ 3 }; … … 129 128 #endif 130 129 131 printf( "=====A=====\n" );130 sout | "=====A====="; 132 131 printA( y0, 0 ); 133 132 printA( y1, 0 ); 134 133 printA( y2, 0 ); 135 printf( "=====A=====\n\n" );134 sout | "=====A=====" | nl | nl; 136 135 137 136 // initialize only first element (z0.a.x), leaving everything else default-initialized (zero), no nested curly-braces … … 172 171 }; 173 172 174 printf( "=====B=====\n" );173 sout | "=====B====="; 175 174 printB( z0, 0 ); 176 175 printB( z1, 0 ); … … 179 178 printB( z5, 0 ); 180 179 printB( z6, 0 ); 181 printf( "=====B=====\n\n" );180 sout | "=====B=====" | nl | nl; 182 181 183 182 // TODO: what about extra things in a nested init? are empty structs skipped?? … … 190 189 }; 191 190 192 printf( "=====C=====\n" );191 sout | "=====C====="; 193 192 printC( c1, 0 ); 194 printf( "=====C=====\n\n" );193 sout | "=====C=====" | nl | nl; 195 194 196 195 #if ERROR … … 246 245 }; 247 246 248 printf( "=====E=====\n" );247 sout | "=====E====="; 249 248 printA( e0.a, 0 ); 250 249 printA( e1.a, 0 ); 251 250 printA( e2.a, 0 ); 252 251 printB( e3.b, 0 ); 253 printf( "=====E=====\n\n" );252 sout | "=====E=====" | nl | nl; 254 253 255 254 // special case of initialization: char[] can be initialized with a string literal
Note: See TracChangeset
for help on using the changeset viewer.