source: tests/array-container/dimexpr-match-c.cfa @ 402a1e7

Last change on this file since 402a1e7 was 0f4ac10, checked in by Michael Brooks <mlbrooks@…>, 17 months ago

Add tests demonstrating CFA's treatment of C arrays, compared with GCC's.

These tests recognize two levels of CFA functionality: Classic and Preview. This commit shows that CFA Master implements Classic. Preview refers to Mike's forthcoming changes.

Only the CFA part runs in the nightly build. Under CFA Classic, a limitation is that only some rejection cases are exercised in the nightly build. A hand-driven testing script can access all the cases and CFA Preview will exercise all the cases in the nightly build.

test dimexpr-match-c: how CFA's treatment of C arrays compares with GCC's

test dimexpr-match-cfa: how CFA's treamtment of <containers/array.hfa>-arrays aligns with the above

  • Property mode set to 100644
File size: 2.9 KB
RevLine 
[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
18DECLN_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}
Note: See TracBrowser for help on using the repository browser.