Changeset a465d751 for tests/designations.cfa
- Timestamp:
- Jan 30, 2025, 10:50:41 AM (11 months ago)
- Branches:
- master
- Children:
- 372d33c
- Parents:
- 161b98e
- File:
-
- 1 edited
-
tests/designations.cfa (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
tests/designations.cfa
r161b98e ra465d751 16 16 // Note: this test case has been crafted so that it compiles with both cfa and with gcc without any modifications. 17 17 #include <stdio.h> 18 18 19 #ifdef __cforall 19 20 #define AT @ … … 24 25 #pragma GCC diagnostic ignored "-Wmissing-braces" 25 26 #pragma GCC diagnostic ignored "-Woverride-init" 26 #pragma GCC diagnostic ignored "-Wunused-variable"27 27 #pragma GCC diagnostic ignored "-Wmissing-field-initializers" 28 28 … … 161 161 // no initializer - legal C, but garbage values - don't print this one 162 162 struct B z4; 163 // Mark this as unused since it can't be printed. 164 (void)z4; 163 165 164 166 // no curly braces - initialize with object of same type … … 220 222 int i1 = { 3 }; 221 223 224 printf( "====ARR====\n" ); 225 printf( "[%d, %d]\n", i[0], i[1] ); 226 printf( "%d\n", i1 ); 227 printf( "====ARR====\n\n" ); 228 222 229 // doesn't work yet. 223 230 // designate unnamed object's members … … 259 266 const char c2[] = "abc"; 260 267 const char c3[] = { 'a', 'b', 'c' }; 261 const char c4[][2] = { { 'a', 'b' }, { 'c', 'd' }, { 'c', 'd'} };268 const char c4[][2] = { { 'a', 'b' }, { 'c', 'd' }, { 'c', 'd' } }; 262 269 const char ch = c4[0][0]; 270 271 printf( "==STRINGS==\n" ); 272 printf( "%s\n", str0 ); 273 printf( "%s\n", str1 ); 274 printf( "%s\n", c2 ); 275 printf( "[%c, %c, %c]\n", c3[0], c3[1], c3[2] ); 276 for ( unsigned index = 0 ; index < 3 ; ++index ) { 277 printf( "[%c, %c]\n", c4[index][0], c4[index][1] ); 278 } 279 printf( "%c\n", ch ); 280 printf( "==STRINGS==\n\n" ); 263 281 264 282 // more cases … … 270 288 union foo { int i; double d; }; 271 289 union foo f = { .d = 4 }; 272 int v1 = 0, v2 = 0, v4 = 0;290 int v1 = 1, v2 = 2, v4 = 4; 273 291 int w[6] = { [1] = v1, v2, [4] = v4 }; 274 292 int whitespace[256] = { [' '] = 1, ['\t'] = 1, ['\v'] = 1, ['\f'] = 1, ['\n'] = 1, ['\r'] = 1 }; 275 293 struct point ptarray[10] = { [2].y = 34, [2].x = 35, [0].x = 36 }; 294 295 printf( "===EXTRA===\n" ); 296 printf( "(point){ %d %d }\n", p.x, p.y ); 297 printf( "(foo){ %f }\n", f.d ); 298 printf( "[%d, %d, %d, %d, %d, %d]\n", w[0], w[1], w[2], w[3], w[4], w[5] ); 299 printf( "[%d ... %d ...]\n", whitespace[0], whitespace[32] ); 300 printf( "[{ %d %d }, { %d %d }, { %d %d } ...]\n", ptarray[0].x, ptarray[0].y, ptarray[1].x, ptarray[1].y, ptarray[2].x, ptarray[2].y ); 301 printf( "===EXTRA===\n\n" ); 276 302 } 277 303
Note:
See TracChangeset
for help on using the changeset viewer.