source: tests/array-collections/dimexpr-match-c.cfa@ 090b076

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

Remove warnings from remaining array-collections tests.

  • Property mode set to 100644
File size: 3.2 KB
Line 
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#ifdef TRY_WISH_1 // "unification as-if"
19forall( [N] )
20void zip( float (*a)[N], float (*b)[N] ) {}
21#endif
22
23DECLN_runTests {
24
25 enum { enu7 = 7, enu42 = 42 };
26 int mut7 = 7, mut42 = 42;
27
28 // Many are only used in rejection cases, so they are unused in the non-ERRS compilation.
29 (void) cpr7;
30 (void) cpr42;
31 (void) mut7;
32 (void) mut42;
33
34 #define TRY_COMPAT( LV, RV ) \
35 { \
36 void f( float (*x)[LV] ) { (void) x; } \
37 float a[RV]; \
38 f( & a ); \
39 }
40 ARRANGEMENT( PTRPARM_CALL )
41 #undef TRY_COMPAT
42
43 #define TRY_COMPAT( LV, RV ) \
44 { \
45 float a[RV]; \
46 float (*b)[LV] = & a; \
47 (void) b; \
48 }
49 ARRANGEMENT( PTRVAR_INIT )
50 #undef TRY_COMPAT
51
52 #define TRY_COMPAT( LV, RV ) \
53 { \
54 float a[RV]; \
55 float (*b)[LV] = NULL; \
56 b = & a; \
57 }
58 ARRANGEMENT( PTRVAR_ASGN )
59 #undef TRY_COMPAT
60
61 #ifdef __cforall
62
63 #ifdef TRY_BUG_1
64 #define TRY_COMPAT( LV, RV ) \
65 { \
66 void f( float (&x)[LV] ) {} \
67 float a[RV]; \
68 f( a ); \
69 }
70 ARRANGEMENT( REFPARM_CALL )
71 #undef TRY_COMPAT
72
73 #define TRY_COMPAT( LV, RV ) \
74 { \
75 float a[RV]; \
76 float (&b)[LV] = a; \
77 }
78 ARRANGEMENT( REFVAR_INIT )
79 #undef TRY_COMPAT
80 #endif
81
82 #define TRY_COMPAT( LV, RV ) \
83 { \
84 float a[RV]; \
85 float (&b)[LV] = *0p; \
86 & b = & a; \
87 }
88 ARRANGEMENT( REFVAR_ASGN )
89 #undef TRY_COMPAT
90
91 #ifdef TRY_WISH_1 // "unification as-if"
92 #define TRY_COMPAT( LV, RV ) \
93 { \
94 float a[LV]; \
95 float b[RV]; \
96 zip( &a, &b ); \
97 }
98 ARRANGEMENT( CALLZIP )
99 #undef TRY_COMPAT
100 #endif
101
102 #endif
103}
Note: See TracBrowser for help on using the repository browser.