| [0f4ac10] | 1 | // These "-c" test cases run the dimexpr-match framework (see the hfa) on the C array. | 
|---|
|  | 2 | // The test is runnable in plain gcc and cfacc. | 
|---|
|  | 3 | // When run in cfacc, it shows the support/compatibility of C arrays in CFA. | 
|---|
|  | 4 |  | 
|---|
|  | 5 | // These tests don't use collections/array.hfa (see the -cfa version for that). | 
|---|
|  | 6 | // But `forall( [N] ) ...` is a laguage feature that does not depend on the new-array library. | 
|---|
|  | 7 | // In CFA, such an `N` is a fine value expression, and can be used as the dimension of a "C" array. | 
|---|
|  | 8 | // This file's cases include `N` expressions when the compiler is non-Classic CFA. | 
|---|
|  | 9 | // They are omitted from consideration | 
|---|
|  | 10 | //  - under gcc, for obvious reasons | 
|---|
|  | 11 | //  - or under classic CFA, beacuase its bahaviour on this C/CFA hybrid was complex, and there is no value in modeling an expctation of it | 
|---|
|  | 12 | //  - whereas these are not really "C compatibility" cases | 
|---|
|  | 13 |  | 
|---|
|  | 14 | #define SUPPRESS_FORALL_N_ON_CLASSIC | 
|---|
|  | 15 |  | 
|---|
|  | 16 | #include "dimexpr-match.hfa"     // test framework | 
|---|
|  | 17 |  | 
|---|
| [e0332dd3] | 18 | #ifdef TRY_WISH_1 // "unification as-if" | 
|---|
|  | 19 | forall( [N] ) | 
|---|
|  | 20 | void zip( float (*a)[N], float (*b)[N] ) {} | 
|---|
|  | 21 | #endif | 
|---|
|  | 22 |  | 
|---|
| [0f4ac10] | 23 | DECLN_runTests { | 
|---|
|  | 24 |  | 
|---|
|  | 25 | enum { enu7 = 7, enu42 = 42 }; | 
|---|
|  | 26 | int mut7 = 7, mut42 = 42; | 
|---|
|  | 27 |  | 
|---|
|  | 28 | #define TRY_COMPAT( LV, RV )        \ | 
|---|
|  | 29 | {                                   \ | 
|---|
|  | 30 | void f( float (*x)[LV] ) {}     \ | 
|---|
|  | 31 | float a[RV];                    \ | 
|---|
|  | 32 | f( & a );                       \ | 
|---|
|  | 33 | } | 
|---|
|  | 34 | ARRANGEMENT( PTRPARM_CALL ) | 
|---|
|  | 35 | #undef TRY_COMPAT | 
|---|
|  | 36 |  | 
|---|
|  | 37 | #define TRY_COMPAT( LV, RV )        \ | 
|---|
|  | 38 | {                                   \ | 
|---|
|  | 39 | float a[RV];                    \ | 
|---|
|  | 40 | float (*b)[LV] = & a;           \ | 
|---|
|  | 41 | } | 
|---|
|  | 42 | ARRANGEMENT( PTRVAR_INIT ) | 
|---|
|  | 43 | #undef TRY_COMPAT | 
|---|
|  | 44 |  | 
|---|
|  | 45 | #define TRY_COMPAT( LV, RV )        \ | 
|---|
|  | 46 | {                                   \ | 
|---|
|  | 47 | float a[RV];                    \ | 
|---|
|  | 48 | float (*b)[LV] = NULL;          \ | 
|---|
|  | 49 | b = & a;                        \ | 
|---|
|  | 50 | } | 
|---|
|  | 51 | ARRANGEMENT( PTRVAR_ASGN ) | 
|---|
|  | 52 | #undef TRY_COMPAT | 
|---|
|  | 53 |  | 
|---|
|  | 54 | #ifdef __cforall | 
|---|
|  | 55 |  | 
|---|
|  | 56 | #ifdef TRY_BUG_1 | 
|---|
|  | 57 | #define TRY_COMPAT( LV, RV )        \ | 
|---|
|  | 58 | {                                   \ | 
|---|
|  | 59 | void f( float (&x)[LV] ) {}     \ | 
|---|
|  | 60 | float a[RV];                    \ | 
|---|
|  | 61 | f( a );                         \ | 
|---|
|  | 62 | } | 
|---|
|  | 63 | ARRANGEMENT( REFPARM_CALL ) | 
|---|
|  | 64 | #undef TRY_COMPAT | 
|---|
|  | 65 |  | 
|---|
|  | 66 | #define TRY_COMPAT( LV, RV )        \ | 
|---|
|  | 67 | {                                   \ | 
|---|
|  | 68 | float a[RV];                    \ | 
|---|
|  | 69 | float (&b)[LV] = a;             \ | 
|---|
|  | 70 | } | 
|---|
|  | 71 | ARRANGEMENT( REFVAR_INIT ) | 
|---|
|  | 72 | #undef TRY_COMPAT | 
|---|
|  | 73 | #endif | 
|---|
|  | 74 |  | 
|---|
|  | 75 | #define TRY_COMPAT( LV, RV )        \ | 
|---|
|  | 76 | {                                   \ | 
|---|
|  | 77 | float a[RV];                    \ | 
|---|
|  | 78 | float (&b)[LV] = *0p;           \ | 
|---|
|  | 79 | & b = & a;                      \ | 
|---|
|  | 80 | } | 
|---|
|  | 81 | ARRANGEMENT( REFVAR_ASGN ) | 
|---|
|  | 82 | #undef TRY_COMPAT | 
|---|
|  | 83 |  | 
|---|
|  | 84 | #ifdef TRY_WISH_1 // "unification as-if" | 
|---|
|  | 85 | #define TRY_COMPAT( LV, RV )        \ | 
|---|
|  | 86 | {                                   \ | 
|---|
|  | 87 | float a[LV];                    \ | 
|---|
|  | 88 | float b[RV];                    \ | 
|---|
|  | 89 | zip( &a, &b );                  \ | 
|---|
|  | 90 | } | 
|---|
|  | 91 | ARRANGEMENT( CALLZIP ) | 
|---|
|  | 92 | #undef TRY_COMPAT | 
|---|
|  | 93 | #endif | 
|---|
|  | 94 |  | 
|---|
|  | 95 | #endif | 
|---|
|  | 96 | } | 
|---|