source: tests/functions.cfa @ 94aa202

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

add updated function-declaration test

  • Property mode set to 100644
File size: 3.6 KB
RevLine 
[c0453ca3]1//
[5ead9f9]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.
[c0453ca3]6//
[dc8511c]7// functions.cfa --
[c0453ca3]8//
[5ead9f9]9// Author           : Peter A. Buhr
10// Created On       : Wed Aug 17 08:39:58 2016
11// Last Modified By : Peter A. Buhr
[56b47b9]12// Last Modified On : Tue Mar  5 11:02:25 2024
13// Update Count     : 34
[c0453ca3]14//
[5ead9f9]15
[51b7345]16// ANSI function definitions
17
[56b47b9]18void h( void ) {}
[51b7345]19
20int f (
[56b47b9]21        int ( void ),
22        int ( int ),
23        int (( void )),
24        int (( int )),
25        void g( void )
26) {
27        (*g)();
[a65d92e]28        g();
29        g = h;
[51b7345]30}
31
32int f1() {}
33int (f2()) {}
[56b47b9]34int (*f3())() {}
[320eb73a]35int * ((f4())) {}
[56b47b9]36int ((*f5()))() {}
[320eb73a]37int * f6() {}
[56b47b9]38int * ( f7)() {}
[320eb73a]39int ** f8() {}
[56b47b9]40int * const * ( f9)() {}
[320eb73a]41int (* f10())[] {}
42int (* f11())[][3] {}
43int ((* f12())[])[3] {}
[51b7345]44
[55ba7339]45// "implicit int" otype specifier (not ANSI)
[51b7345]46
47fII1( int i ) {}
48const fII2( int i ) {}
49extern fII3( int i ) {}
50extern const fII4( int i ) {}
51
[320eb73a]52* fII5() {}
53const * fII6() {}
54const long * fII7() {}
55static const long * fII8() {}
56const static long * fII9() {}
[51b7345]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
[56b47b9]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 ) {}
[51b7345]116
[481115f]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
[51b7345]126
127[int] f(
128        int ( int, int p ),
129        [int](int)
[56b47b9]130) {
131        int (* (* pc )[][10])[][3];
[a65d92e]132        * [][10] * [][3] int p;
[56b47b9]133        * [] * [int]( int ) p;
[51b7345]134}
135
[320eb73a]136static const int * f1() {}
[c0453ca3]137static [ * const int ] f2() {}
[51b7345]138static inline [ const * int ] f3() {}
139static inline [ const [ * int, int ] ] f4() {}
140static [ const [ * int, const int ] ] f5() {}
141
142// unnamed parameter
143
144int f(
[a65d92e]145        int (),
146
[320eb73a]147        int * (),
148        int ** (),
149        int * const * (),
[a65d92e]150        int * const * const (),
151
152        int ([]),
153        int ([10]),
154
[320eb73a]155        int * ([]),
156        int * ([10]),
157        int ** ([]),
158        int ** ([10]),
159        int * const * ([]),
160        int * const * ([10]),
[a65d92e]161        int * const * const ([]),
162        int * const * const ([10])
[56b47b9]163);
[51b7345]164
165int f(
[a65d92e]166        int (),
167
[320eb73a]168        int * (),
169        int ** (),
170        int * const * (),
[a65d92e]171        int * const * const (),
172
173        int ([]),
174        int ([10]),
175
[320eb73a]176        int * ([]),
177        int * ([10]),
178        int ** ([]),
179        int ** ([10]),
180        int * const * ([]),
181        int * const * ([10]),
[a65d92e]182        int * const * const ([]),
183        int * const * const ([10])
[56b47b9]184) {}
[51b7345]185
186typedef int T;
187
[56b47b9]188int f( T ( *f ), T t ) {
189        T ( T );
[51b7345]190}
191
192// errors
193
194//int f()[] {}
195//int (f[])() {}
196//int f[]() {}
[320eb73a]197//int ((* f15())())[] {}
[a65d92e]198
199// Local Variables: //
200// tab-width: 4 //
[dc8511c]201// compile-command: "cfa functions.cfa" //
[a65d92e]202// End: //
Note: See TracBrowser for help on using the repository browser.