source: tests/functions.cfa @ ce0b8b8

Last change on this file since ce0b8b8 was 56b47b9, checked in by Peter A. Buhr <pabuhr@…>, 8 months ago

add updated function-declaration test

  • Property mode set to 100644
File size: 3.6 KB
Line 
1//
2// Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo
3//
4// The contents of this file are covered under the licence agreement in the
5// file "LICENCE" distributed with Cforall.
6//
7// functions.cfa --
8//
9// Author           : Peter A. Buhr
10// Created On       : Wed Aug 17 08:39:58 2016
11// Last Modified By : Peter A. Buhr
12// Last Modified On : Tue Mar  5 11:02:25 2024
13// Update Count     : 34
14//
15
16// ANSI function definitions
17
18void h( void ) {}
19
20int f (
21        int ( void ),
22        int ( int ),
23        int (( void )),
24        int (( int )),
25        void g( void )
26) {
27        (*g)();
28        g();
29        g = h;
30}
31
32int f1() {}
33int (f2()) {}
34int (*f3())() {}
35int * ((f4())) {}
36int ((*f5()))() {}
37int * f6() {}
38int * ( f7)() {}
39int ** f8() {}
40int * const * ( f9)() {}
41int (* f10())[] {}
42int (* f11())[][3] {}
43int ((* f12())[])[3] {}
44
45// "implicit int" otype specifier (not ANSI)
46
47fII1( int i ) {}
48const fII2( int i ) {}
49extern fII3( int i ) {}
50extern const fII4( int i ) {}
51
52* fII5() {}
53const * fII6() {}
54const long * fII7() {}
55static const long * fII8() {}
56const static long * fII9() {}
57
58// K&R function definitions
59
60fO1( i ) int i; {}
61int fO2( i ) int i; {}
62const fO3( i ) int i; {}
63extern fO4( i ) int i; {}
64extern const fO5( i ) int i; {}
65
66// Cforall extensions
67
68[] f();
69[void] f();
70[int] f();
71[] f( int );
72[void] f( int );
73[int] f( int );
74[] f() {}
75[void] fv() {}
76[int] f() {}
77[] f( int ) {}
78[void] fv( int ) {}
79[int] f( int ) {}
80
81[int x] f();
82[] f( int x );
83[void] fv( int x );
84//[int x] f( int x );
85//[int x] f() {}
86[] f2( int x ) {}
87[void] fv1( int x ) {}
88//[int x] f( int x ) {}
89
90[int, int x] f();
91[] f( int, int x );
92[void] fv( int, int x );
93[int, int x] f( int, int x );
94[int, int x] f() {}
95[] f( int, int x ) {}
96[void] fv( int, int x ) {}
97[int, int x] f( int, int x ) {}
98
99[int, int x, int] f();
100[] f( int, int x, int );
101[void] fv( int, int x, int );
102[int, int x, int] f( int, int x, int );
103[int, int x, int] f() {}
104[] f( int, int x, int ) {}
105[void] fv( int, int x, int ) {}
106[int, int x, int] f( int, int x, int ) {}
107
108[int, int x, * int y] f();
109[] f( int, int x, * int y );
110[void] fv( int, int x, * int y );
111[int, int x, * int y] f( int, int x, * int y );
112[int, int x, * int y] f() {}
113[] f( int, int x, * int y ) {}
114[void] fv( int, int x, * int y ) {}
115[int, int x, * int y] f( int, int x, * int y ) {}
116
117// function prototypes
118
119[ int ] f11( int ), f12();  // => int f11( int ), f12( void );
120
121const double bar1(), bar2( int ), bar3( double );               // C version
122[const double] foo(), foo( int ), foo( double ) { return 3.0; } // CFA version
123struct S { int i; };
124[S] rtn( int ) {}
125
126
127[int] f(
128        int ( int, int p ),
129        [int](int)
130) {
131        int (* (* pc )[][10])[][3];
132        * [][10] * [][3] int p;
133        * [] * [int]( int ) p;
134}
135
136static const int * f1() {}
137static [ * const int ] f2() {}
138static inline [ const * int ] f3() {}
139static inline [ const [ * int, int ] ] f4() {}
140static [ const [ * int, const int ] ] f5() {}
141
142// unnamed parameter
143
144int f(
145        int (),
146
147        int * (),
148        int ** (),
149        int * const * (),
150        int * const * const (),
151
152        int ([]),
153        int ([10]),
154
155        int * ([]),
156        int * ([10]),
157        int ** ([]),
158        int ** ([10]),
159        int * const * ([]),
160        int * const * ([10]),
161        int * const * const ([]),
162        int * const * const ([10])
163);
164
165int f(
166        int (),
167
168        int * (),
169        int ** (),
170        int * const * (),
171        int * const * const (),
172
173        int ([]),
174        int ([10]),
175
176        int * ([]),
177        int * ([10]),
178        int ** ([]),
179        int ** ([10]),
180        int * const * ([]),
181        int * const * ([10]),
182        int * const * const ([]),
183        int * const * const ([10])
184) {}
185
186typedef int T;
187
188int f( T ( *f ), T t ) {
189        T ( T );
190}
191
192// errors
193
194//int f()[] {}
195//int (f[])() {}
196//int f[]() {}
197//int ((* f15())())[] {}
198
199// Local Variables: //
200// tab-width: 4 //
201// compile-command: "cfa functions.cfa" //
202// End: //
Note: See TracBrowser for help on using the repository browser.