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.c --
|
---|
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 : Wed Jan 17 22:44:12 2018
|
---|
13 | // Update Count : 12
|
---|
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 | [int] f( );
|
---|
70 | // [] f(int);
|
---|
71 | [int] f(int);
|
---|
72 | // [] f( ) {}
|
---|
73 | [int] f( ) {}
|
---|
74 | // [] f(int) {}
|
---|
75 | [int] f(int) {}
|
---|
76 |
|
---|
77 | [int x] f( );
|
---|
78 | // [] f(int x);
|
---|
79 | //[int x] f(int x);
|
---|
80 | //[int x] f( ) {}
|
---|
81 | // [] f(int x) {}
|
---|
82 | //[int x] f(int x) {}
|
---|
83 |
|
---|
84 | [int, int x] f( );
|
---|
85 | // [] f(int, int x);
|
---|
86 | [int, int x] f(int, int x);
|
---|
87 | [int, int x] f( ) {}
|
---|
88 | // [] f(int, int x) {}
|
---|
89 | [int, int x] f(int, int x) {}
|
---|
90 |
|
---|
91 | [int, int x, int] f( );
|
---|
92 | // [] f(int, int x, int);
|
---|
93 | [int, int x, int] f(int, int x, int);
|
---|
94 | [int, int x, int] f( ) {}
|
---|
95 | // [] f(int, int x, int) {}
|
---|
96 | [int, int x, int] f(int, int x, int) {}
|
---|
97 |
|
---|
98 | [int, int x, * int y] f( );
|
---|
99 | // [] f(int, int x, * int y);
|
---|
100 | [int, int x, * int y] f(int, int x, * int y);
|
---|
101 | [int, int x, * int y] f( ) {}
|
---|
102 | // [] f(int, int x, * int y) {}
|
---|
103 | [int, int x, * int y] f(int, int x, * int y) {}
|
---|
104 |
|
---|
105 | // function prototypes
|
---|
106 |
|
---|
107 | [ int ] f11( int ), f12(); // => int f11( int ), f12( void );
|
---|
108 |
|
---|
109 | const double bar1(), bar2( int ), bar3( double ); // C version
|
---|
110 | [const double] foo(), foo( int ), foo( double ) { return 3.0; } // CFA version
|
---|
111 | struct S { int i; };
|
---|
112 | [S] rtn( int ) {}
|
---|
113 |
|
---|
114 |
|
---|
115 | [int] f(
|
---|
116 | int ( int, int p ),
|
---|
117 | [int](int)
|
---|
118 | ) {
|
---|
119 | int (* (* pc)[][10])[][3];
|
---|
120 | * [][10] * [][3] int p;
|
---|
121 | * [] * [int](int) p;
|
---|
122 | }
|
---|
123 |
|
---|
124 | static const int * f1() {}
|
---|
125 | static [ * const int ] f2() {}
|
---|
126 | static inline [ const * int ] f3() {}
|
---|
127 | static inline [ const [ * int, int ] ] f4() {}
|
---|
128 | static [ const [ * int, const int ] ] f5() {}
|
---|
129 |
|
---|
130 | // unnamed parameter
|
---|
131 |
|
---|
132 | int f(
|
---|
133 | int (),
|
---|
134 |
|
---|
135 | int * (),
|
---|
136 | int ** (),
|
---|
137 | int * const * (),
|
---|
138 | int * const * const (),
|
---|
139 |
|
---|
140 | int ([]),
|
---|
141 | int ([10]),
|
---|
142 |
|
---|
143 | int * ([]),
|
---|
144 | int * ([10]),
|
---|
145 | int ** ([]),
|
---|
146 | int ** ([10]),
|
---|
147 | int * const * ([]),
|
---|
148 | int * const * ([10]),
|
---|
149 | int * const * const ([]),
|
---|
150 | int * const * const ([10])
|
---|
151 | );
|
---|
152 |
|
---|
153 | int f(
|
---|
154 | int (),
|
---|
155 |
|
---|
156 | int * (),
|
---|
157 | int ** (),
|
---|
158 | int * const * (),
|
---|
159 | int * const * const (),
|
---|
160 |
|
---|
161 | int ([]),
|
---|
162 | int ([10]),
|
---|
163 |
|
---|
164 | int * ([]),
|
---|
165 | int * ([10]),
|
---|
166 | int ** ([]),
|
---|
167 | int ** ([10]),
|
---|
168 | int * const * ([]),
|
---|
169 | int * const * ([10]),
|
---|
170 | int * const * const ([]),
|
---|
171 | int * const * const ([10])
|
---|
172 | ) {
|
---|
173 | }
|
---|
174 |
|
---|
175 | typedef int T;
|
---|
176 |
|
---|
177 | int f( T (* f), T t ) {
|
---|
178 | T (T);
|
---|
179 | }
|
---|
180 |
|
---|
181 | // errors
|
---|
182 |
|
---|
183 | //int f()[] {}
|
---|
184 | //int (f[])() {}
|
---|
185 | //int f[]() {}
|
---|
186 | //int ((* f15())())[] {}
|
---|
187 |
|
---|
188 | // Local Variables: //
|
---|
189 | // tab-width: 4 //
|
---|
190 | // compile-command: "cfa functions.c" //
|
---|
191 | // End: //
|
---|