| [0f4ac10] | 1 | // These "-cfa" test cases run the dimexpr-match framework (see the hfa) on the CFA "new array." | 
|---|
|  | 2 | // The test is not runnable in gcc. | 
|---|
|  | 3 | // Essentially parallels dimexpr-match.cfa, but uses array(float, 17), of array.hfa, in place of `float[17]`. | 
|---|
|  | 4 |  | 
|---|
|  | 5 | #ifndef __cforall | 
|---|
|  | 6 | #error This test is CFA-only | 
|---|
|  | 7 | #endif | 
|---|
|  | 8 |  | 
|---|
|  | 9 | #ifdef INCLUDE_MINIMAL | 
|---|
|  | 10 | #define POUNDINCLUDE #include | 
|---|
|  | 11 | POUNDINCLUDE <containers/array.hfa> | 
|---|
|  | 12 | #else | 
|---|
|  | 13 | #include <containers/array.hfa>                           // part of SUT | 
|---|
|  | 14 | #endif | 
|---|
|  | 15 |  | 
|---|
|  | 16 | #include "dimexpr-match.hfa"                              // test framework | 
|---|
|  | 17 |  | 
|---|
|  | 18 | // CFA "classic" behaviour is inconsistent between "C array" and "new array." | 
|---|
|  | 19 | // The impelementation of "non classic" rules makes C arrays and new arrays work the same. | 
|---|
|  | 20 | #ifdef CFA_IS_CLASSIC | 
|---|
|  | 21 |  | 
|---|
|  | 22 | // CFA "classic" allows mismatched static lengths on "new arrays," which is a bug. | 
|---|
|  | 23 | // For cfacc-classic compiling C arrays, the (expected) rejection of mismatched static lenghts happens in gcc, not cfa-cpp. | 
|---|
|  | 24 | // When the CFA input is a C array, the cfa-cc handling is passthrough, so GCC sees the error. | 
|---|
|  | 25 | // When the CFA input is a new array, the cfa-cpp handling is nontrivial; this rewriting hides the error from GCC, causing the case to be accepted. | 
|---|
|  | 26 | // This issue is fixed in the implementation of the "non classic" rules. | 
|---|
|  | 27 | #undef  RULE_CF_NE_STA_STA | 
|---|
|  | 28 | #define RULE_CF_NE_STA_STA  ACC | 
|---|
|  | 29 |  | 
|---|
|  | 30 | // CFA "classic" rejects mismatched `[N]`s on "new arrays," which is the original signature featere of "new arrays." | 
|---|
|  | 31 | // But it is unable to do the same with `n`s.  So CFA "classic" treats `n` and `[N]` differently. | 
|---|
|  | 32 | // The impelementation of "non classic" rules extends this safety to `n`s, and to C arrays. | 
|---|
|  | 33 | #undef  GRP_K_DIM                 // reclassify dim7/dim42 as group XXX, instead of group DYN | 
|---|
|  | 34 | #define GRP_K_DIM  XXX | 
|---|
|  | 35 | #define RULE_CF_EQ_XXX_XXX  ACC   // these rules correspond with non-"classic" DYN | 
|---|
|  | 36 | #define RULE_CF_NE_XXX_XXX  REJ | 
|---|
|  | 37 | #define RULE_CF_NE_XXX_STA  REJ | 
|---|
|  | 38 | #define RULE_CF_NE_STA_XXX  REJ | 
|---|
|  | 39 | #define RULE_CF_NE_XXX_DYN  REJ | 
|---|
|  | 40 | #define RULE_CF_NE_DYN_XXX  REJ | 
|---|
|  | 41 | #define RULE_CF_NE_XXX_UNS  REJ | 
|---|
|  | 42 | #define RULE_CF_NE_UNS_XXX  REJ | 
|---|
|  | 43 |  | 
|---|
|  | 44 | #endif | 
|---|
|  | 45 |  | 
|---|
|  | 46 |  | 
|---|
|  | 47 | DECLN_runTests { | 
|---|
|  | 48 |  | 
|---|
|  | 49 | enum { enu7 = 7, enu42 = 42 }; | 
|---|
|  | 50 | int mut7 = 7, mut42 = 42; | 
|---|
|  | 51 |  | 
|---|
|  | 52 |  | 
|---|
|  | 53 | #define TRY_COMPAT( LV, RV )            \ | 
|---|
|  | 54 | {                                       \ | 
|---|
|  | 55 | void f( array(float, LV) * x ) {}   \ | 
|---|
|  | 56 | array(float, RV) a;                 \ | 
|---|
|  | 57 | f( & a );                           \ | 
|---|
|  | 58 | } | 
|---|
|  | 59 | ARRANGEMENT( PTRPARM_CALL ) | 
|---|
|  | 60 | #undef TRY_COMPAT | 
|---|
|  | 61 |  | 
|---|
|  | 62 | #define TRY_COMPAT( LV, RV )            \ | 
|---|
|  | 63 | {                                       \ | 
|---|
|  | 64 | array(float, RV) a;                 \ | 
|---|
|  | 65 | array(float, LV) * b = & a;         \ | 
|---|
|  | 66 | } | 
|---|
|  | 67 | ARRANGEMENT( PTRVAR_INIT ) | 
|---|
|  | 68 | #undef TRY_COMPAT | 
|---|
|  | 69 |  | 
|---|
|  | 70 | #define TRY_COMPAT( LV, RV )            \ | 
|---|
|  | 71 | {                                       \ | 
|---|
|  | 72 | array(float, RV) a;                 \ | 
|---|
|  | 73 | array(float, LV) * b = NULL;        \ | 
|---|
|  | 74 | b = & a;                            \ | 
|---|
|  | 75 | } | 
|---|
|  | 76 | ARRANGEMENT( PTRVAR_ASGN ) | 
|---|
|  | 77 | #undef TRY_COMPAT | 
|---|
|  | 78 |  | 
|---|
|  | 79 | #define TRY_COMPAT( LV, RV )            \ | 
|---|
|  | 80 | {                                       \ | 
|---|
|  | 81 | void f( array(float, LV) & x ) {}   \ | 
|---|
|  | 82 | array(float, RV) a;                 \ | 
|---|
|  | 83 | f( a );                             \ | 
|---|
|  | 84 | } | 
|---|
|  | 85 | ARRANGEMENT( REFPARM_CALL ) | 
|---|
|  | 86 | #undef TRY_COMPAT | 
|---|
|  | 87 |  | 
|---|
|  | 88 | #define TRY_COMPAT( LV, RV )            \ | 
|---|
|  | 89 | {                                       \ | 
|---|
|  | 90 | array(float, RV) a;                 \ | 
|---|
|  | 91 | array(float, LV) & b = a;           \ | 
|---|
|  | 92 | } | 
|---|
|  | 93 | ARRANGEMENT( REFVAR_INIT ) | 
|---|
|  | 94 | #undef TRY_COMPAT | 
|---|
|  | 95 |  | 
|---|
|  | 96 | #define TRY_COMPAT( LV, RV )            \ | 
|---|
|  | 97 | {                                       \ | 
|---|
|  | 98 | array(float, RV) a;                 \ | 
|---|
|  | 99 | array(float, LV) & b = *0p;         \ | 
|---|
|  | 100 | & b = & a;                          \ | 
|---|
|  | 101 | } | 
|---|
|  | 102 | ARRANGEMENT( REFVAR_ASGN ) | 
|---|
|  | 103 | #undef TRY_COMPAT | 
|---|
|  | 104 |  | 
|---|
|  | 105 |  | 
|---|
|  | 106 | forall( [N] ) | 
|---|
|  | 107 | void zip( array(float, N) & a, array(float, N) & b ) {} | 
|---|
|  | 108 |  | 
|---|
|  | 109 | #define TRY_COMPAT( LV, RV )            \ | 
|---|
|  | 110 | {                                       \ | 
|---|
|  | 111 | array(float, LV) a;                 \ | 
|---|
|  | 112 | array(float, RV) b;                 \ | 
|---|
|  | 113 | zip( a, b );                        \ | 
|---|
|  | 114 | } | 
|---|
|  | 115 | ARRANGEMENT( CALLZIP ) | 
|---|
|  | 116 | #undef TRY_COMPAT | 
|---|
|  | 117 |  | 
|---|
|  | 118 | } | 
|---|