// -*- Mode: C -*- // // Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo // // The contents of this file are covered under the licence agreement in the // file "LICENCE" distributed with Cforall. // // array.cfa -- test array declarations // // Author : Peter A. Buhr // Created On : Tue Feb 19 21:18:06 2019 // Last Modified By : Peter A. Buhr // Last Modified On : Sat Jun 5 10:05:51 2021 // Update Count : 5 // // Tests syntax. Comments explain semantics. Test does not show semantics. // Mostly illustrates facts about C (with which CFA is being tested to agree). // Is a test oracle under `gcc -x c`. #ifdef ERR1 #define E1(...) __VA_ARGS__ #else #define E1(...) #endif #ifdef ERR2 #define E2(...) __VA_ARGS__ #else #define E2(...) #endif #ifdef ERR3 #define E3(...) __VA_ARGS__ #else #define E3(...) #endif int a1[0]; E1( int a2[*]; ) #ifndef __cforall E1( double a4[3.0]; ) // BUG 275: CFA accepts but should reject #endif int m1[0][3]; E1( int m2[*][*]; ) int m4[3][3]; typedef int T; int fred(int n) { E1( int a1[]; ) E1( int a2[*]; ) int a4[3]; int T[3]; int a5[n]; } int mary( int T[3], // same as: int *T int p1[const 3], // same as: int const *p1 int p2[static 3], // same as T, but length >=3 checked int p3[static const 3] // both above: 3 is static, p3 is const ) { } // function taking (), returning pointer to array of ints int (*tom())[3] { } // function taking (), returning pointer to function of same type as mary int (*(jane)())( int T[3], int p1[const 3], int p2[static 3], int p3[static const 3] ) { } // functions returning same exotic pointers, in CFA's non-onion syntax #ifdef __cforall [ * [3] int ] toms_twin(...) { } [ * [int]( [3] int T, [const 3] int p1, [static 3] int p2, [static const 3] int p3 ) ] janes_twin(...) { } #endif // int fm1( int, int, int[][*] ); // TODO: investigate gcc-11 warning // int fm1( int r, int c, int m[][c] ) {} int fm2( int r, int c, int (*m)[c] ) {} // same as fm1 E2( int fm3( int r, int c, int m[][static c] ) {} ) // that's not static E3( int fm4( int r, int c, int m[][] ); ) // m's immediate element type is incomplete int fm5( int, int, int[*][*] ); // same as fm1 decl #ifndef __cforall int fm5( int r, int c, int m[r][c] ) {} // BUG 276: CFA chokes but should accept // C: same as fm1 defn #endif int main() { #pragma GCC warning "Preprocessor started" // force non-empty .expect file, NO TABS!!! } // Local Variables: // // tab-width: 4 // // compile-command: "cfa array.cfa" // // End: //