| [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 | 
 | 
|---|
 | 18 | DECLN_runTests {
 | 
|---|
 | 19 | 
 | 
|---|
 | 20 |     enum { enu7 = 7, enu42 = 42 };
 | 
|---|
 | 21 |     int mut7 = 7, mut42 = 42;
 | 
|---|
 | 22 | 
 | 
|---|
 | 23 |     
 | 
|---|
 | 24 |     #define TRY_COMPAT( LV, RV )        \
 | 
|---|
 | 25 |     {                                   \
 | 
|---|
 | 26 |         void f( float (*x)[LV] ) {}     \
 | 
|---|
 | 27 |         float a[RV];                    \
 | 
|---|
 | 28 |         f( & a );                       \
 | 
|---|
 | 29 |     }
 | 
|---|
 | 30 |     ARRANGEMENT( PTRPARM_CALL )
 | 
|---|
 | 31 |     #undef TRY_COMPAT
 | 
|---|
 | 32 | 
 | 
|---|
 | 33 |     #define TRY_COMPAT( LV, RV )        \
 | 
|---|
 | 34 |     {                                   \
 | 
|---|
 | 35 |         float a[RV];                    \
 | 
|---|
 | 36 |         float (*b)[LV] = & a;           \
 | 
|---|
 | 37 |     }
 | 
|---|
 | 38 |     ARRANGEMENT( PTRVAR_INIT )
 | 
|---|
 | 39 |     #undef TRY_COMPAT
 | 
|---|
 | 40 | 
 | 
|---|
 | 41 |     #define TRY_COMPAT( LV, RV )        \
 | 
|---|
 | 42 |     {                                   \
 | 
|---|
 | 43 |         float a[RV];                    \
 | 
|---|
 | 44 |         float (*b)[LV] = NULL;          \
 | 
|---|
 | 45 |         b = & a;                        \
 | 
|---|
 | 46 |     }
 | 
|---|
 | 47 |     ARRANGEMENT( PTRVAR_ASGN )
 | 
|---|
 | 48 |     #undef TRY_COMPAT
 | 
|---|
 | 49 | 
 | 
|---|
 | 50 |   #ifdef __cforall
 | 
|---|
 | 51 | 
 | 
|---|
 | 52 |   #ifdef TRY_BUG_1
 | 
|---|
 | 53 |     #define TRY_COMPAT( LV, RV )        \
 | 
|---|
 | 54 |     {                                   \
 | 
|---|
 | 55 |         void f( float (&x)[LV] ) {}     \
 | 
|---|
 | 56 |         float a[RV];                    \
 | 
|---|
 | 57 |         f( a );                         \
 | 
|---|
 | 58 |     }
 | 
|---|
 | 59 |     ARRANGEMENT( REFPARM_CALL )
 | 
|---|
 | 60 |     #undef TRY_COMPAT
 | 
|---|
 | 61 | 
 | 
|---|
 | 62 |     #define TRY_COMPAT( LV, RV )        \
 | 
|---|
 | 63 |     {                                   \
 | 
|---|
 | 64 |         float a[RV];                    \
 | 
|---|
 | 65 |         float (&b)[LV] = a;             \
 | 
|---|
 | 66 |     }
 | 
|---|
 | 67 |     ARRANGEMENT( REFVAR_INIT )
 | 
|---|
 | 68 |     #undef TRY_COMPAT
 | 
|---|
 | 69 |   #endif
 | 
|---|
 | 70 | 
 | 
|---|
 | 71 |     #define TRY_COMPAT( LV, RV )        \
 | 
|---|
 | 72 |     {                                   \
 | 
|---|
 | 73 |         float a[RV];                    \
 | 
|---|
 | 74 |         float (&b)[LV] = *0p;           \
 | 
|---|
 | 75 |         & b = & a;                      \
 | 
|---|
 | 76 |     }
 | 
|---|
 | 77 |     ARRANGEMENT( REFVAR_ASGN )
 | 
|---|
 | 78 |     #undef TRY_COMPAT
 | 
|---|
 | 79 | 
 | 
|---|
 | 80 |   #ifdef TRY_WISH_1 // "unification as-if"
 | 
|---|
 | 81 |     forall( [N] )
 | 
|---|
 | 82 |     void zip( float (*a)[N], float (*b)[N] ) {}
 | 
|---|
 | 83 | 
 | 
|---|
 | 84 |     #define TRY_COMPAT( LV, RV )        \
 | 
|---|
 | 85 |     {                                   \
 | 
|---|
 | 86 |         float a[LV];                    \
 | 
|---|
 | 87 |         float b[RV];                    \
 | 
|---|
 | 88 |         zip( &a, &b );                  \
 | 
|---|
 | 89 |     }
 | 
|---|
 | 90 |     ARRANGEMENT( CALLZIP )
 | 
|---|
 | 91 |     #undef TRY_COMPAT
 | 
|---|
 | 92 |   #endif
 | 
|---|
 | 93 | 
 | 
|---|
 | 94 |   #endif
 | 
|---|
 | 95 | 
 | 
|---|
 | 96 | 
 | 
|---|
 | 97 | 
 | 
|---|
 | 98 | }
 | 
|---|