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 | |
---|
18 | void h( void ) {} |
---|
19 | |
---|
20 | int 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 | |
---|
32 | int f1() {} |
---|
33 | int (f2()) {} |
---|
34 | int (*f3())() {} |
---|
35 | int * ((f4())) {} |
---|
36 | int ((*f5()))() {} |
---|
37 | int * f6() {} |
---|
38 | int * ( f7)() {} |
---|
39 | int ** f8() {} |
---|
40 | int * const * ( f9)() {} |
---|
41 | int (* f10())[] {} |
---|
42 | int (* f11())[][3] {} |
---|
43 | int ((* f12())[])[3] {} |
---|
44 | |
---|
45 | // "implicit int" otype specifier (not ANSI) |
---|
46 | |
---|
47 | fII1( int i ) {} |
---|
48 | const fII2( int i ) {} |
---|
49 | extern fII3( int i ) {} |
---|
50 | extern const fII4( int i ) {} |
---|
51 | |
---|
52 | * fII5() {} |
---|
53 | const * fII6() {} |
---|
54 | const long * fII7() {} |
---|
55 | static const long * fII8() {} |
---|
56 | const static long * fII9() {} |
---|
57 | |
---|
58 | // K&R function definitions |
---|
59 | |
---|
60 | fO1( i ) int i; {} |
---|
61 | int fO2( i ) int i; {} |
---|
62 | const fO3( i ) int i; {} |
---|
63 | extern fO4( i ) int i; {} |
---|
64 | extern 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 | |
---|
121 | const double bar1(), bar2( int ), bar3( double ); // C version |
---|
122 | [const double] foo(), foo( int ), foo( double ) { return 3.0; } // CFA version |
---|
123 | struct 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 | |
---|
136 | static const int * f1() {} |
---|
137 | static [ * const int ] f2() {} |
---|
138 | static inline [ const * int ] f3() {} |
---|
139 | static inline [ const [ * int, int ] ] f4() {} |
---|
140 | static [ const [ * int, const int ] ] f5() {} |
---|
141 | |
---|
142 | // unnamed parameter |
---|
143 | |
---|
144 | int 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 | |
---|
165 | int 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 | |
---|
186 | typedef int T; |
---|
187 | |
---|
188 | int 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: // |
---|