source: tests/array-collections/dimexpr-match-cfa.cfa@ b28ce93

Last change on this file since b28ce93 was 2e63915, checked in by Michael Brooks <mlbrooks@…>, 9 months ago

Remove warnings from remaining array-collections tests.

  • Property mode set to 100644
File size: 4.3 KB
RevLine 
[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
[55b060d]11POUNDINCLUDE <collections/array.hfa>
[0f4ac10]12#else
[55b060d]13#include <collections/array.hfa> // part of SUT
[0f4ac10]14#endif
15
[55b060d]16#include "dimexpr-match.hfa" // test framework
[0f4ac10]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
[e0332dd3]46forall( [N] )
[2e63915]47void zip( array(float, N) &, array(float, N) & ) {}
[0f4ac10]48
49DECLN_runTests {
50
51 enum { enu7 = 7, enu42 = 42 };
52 int mut7 = 7, mut42 = 42;
53
[2e63915]54 // Many are only used in rejection cases, so they are unused in the non-ERRS compilation.
55 (void) cpr7;
56 (void) cpr42;
57 (void) mut7;
58 (void) mut42;
59
[0f4ac10]60 #define TRY_COMPAT( LV, RV ) \
61 { \
[2e63915]62 void f( array(float, LV) * ) {} \
[0f4ac10]63 array(float, RV) a; \
64 f( & a ); \
65 }
66 ARRANGEMENT( PTRPARM_CALL )
67 #undef TRY_COMPAT
68
69 #define TRY_COMPAT( LV, RV ) \
70 { \
71 array(float, RV) a; \
72 array(float, LV) * b = & a; \
[2e63915]73 (void) b; \
[0f4ac10]74 }
75 ARRANGEMENT( PTRVAR_INIT )
76 #undef TRY_COMPAT
77
78 #define TRY_COMPAT( LV, RV ) \
79 { \
80 array(float, RV) a; \
81 array(float, LV) * b = NULL; \
82 b = & a; \
83 }
84 ARRANGEMENT( PTRVAR_ASGN )
85 #undef TRY_COMPAT
86
87 #define TRY_COMPAT( LV, RV ) \
88 { \
[2e63915]89 void f( array(float, LV) & ) {} \
[0f4ac10]90 array(float, RV) a; \
91 f( a ); \
92 }
93 ARRANGEMENT( REFPARM_CALL )
94 #undef TRY_COMPAT
95
96 #define TRY_COMPAT( LV, RV ) \
97 { \
98 array(float, RV) a; \
99 array(float, LV) & b = a; \
[2e63915]100 (void) b; \
[0f4ac10]101 }
102 ARRANGEMENT( REFVAR_INIT )
103 #undef TRY_COMPAT
104
105 #define TRY_COMPAT( LV, RV ) \
106 { \
107 array(float, RV) a; \
108 array(float, LV) & b = *0p; \
109 & b = & a; \
110 }
111 ARRANGEMENT( REFVAR_ASGN )
112 #undef TRY_COMPAT
113
114 #define TRY_COMPAT( LV, RV ) \
115 { \
116 array(float, LV) a; \
117 array(float, RV) b; \
118 zip( a, b ); \
119 }
120 ARRANGEMENT( CALLZIP )
121 #undef TRY_COMPAT
122
123}
Note: See TracBrowser for help on using the repository browser.