| [5ead9f9] | 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 Aug 17 08:40:52 2016
 | 
|---|
 | 13 | // Update Count     : 1
 | 
|---|
 | 14 | // 
 | 
|---|
 | 15 | 
 | 
|---|
| [51b73452] | 16 | // ANSI function definitions
 | 
|---|
 | 17 | 
 | 
|---|
 | 18 | void h(void) {}
 | 
|---|
 | 19 | 
 | 
|---|
 | 20 | int f (
 | 
|---|
| [a65d92e] | 21 |         int (void),
 | 
|---|
 | 22 |         int (int),
 | 
|---|
 | 23 |         int ((void)),
 | 
|---|
 | 24 |         int ((int)),
 | 
|---|
 | 25 |         void g(void)
 | 
|---|
 | 26 |         ) {
 | 
|---|
 | 27 |         (*g)();
 | 
|---|
 | 28 |         g();
 | 
|---|
 | 29 |         g = h;
 | 
|---|
| [51b73452] | 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 | 
 | 
|---|
| [55ba7339] | 45 | // "implicit int" otype specifier (not ANSI)
 | 
|---|
| [51b73452] | 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 | [ int ] f11( int ), f12;  // => int f11( int ), f12( int );
 | 
|---|
 | 106 | 
 | 
|---|
 | 107 | [int] f(
 | 
|---|
 | 108 |         int ( int, int p ),
 | 
|---|
 | 109 |         [int](int)
 | 
|---|
| [a65d92e] | 110 |         ) {
 | 
|---|
 | 111 |         int (*(*p)[][10])[][3];
 | 
|---|
 | 112 |         * [][10] * [][3] int p;
 | 
|---|
 | 113 |         * [] * [int](int) p;
 | 
|---|
| [51b73452] | 114 | }
 | 
|---|
 | 115 | 
 | 
|---|
 | 116 | static const int *f1() {}
 | 
|---|
 | 117 | static [ const int ] f2() {}
 | 
|---|
 | 118 | static inline [ const * int ] f3() {}
 | 
|---|
 | 119 | static inline [ const [ * int, int ] ] f4() {}
 | 
|---|
 | 120 | static [ const [ * int, const int ] ] f5() {}
 | 
|---|
 | 121 | 
 | 
|---|
 | 122 | // unnamed parameter
 | 
|---|
 | 123 | 
 | 
|---|
 | 124 | int f(
 | 
|---|
| [a65d92e] | 125 |         int (),
 | 
|---|
 | 126 | 
 | 
|---|
 | 127 |         int *(),
 | 
|---|
 | 128 |         int **(),
 | 
|---|
 | 129 |         int * const *(),
 | 
|---|
 | 130 |         int * const * const (),
 | 
|---|
 | 131 | 
 | 
|---|
 | 132 |         int ([]),
 | 
|---|
 | 133 |         int ([10]),
 | 
|---|
 | 134 | 
 | 
|---|
 | 135 |         int *([]),
 | 
|---|
 | 136 |         int *([10]),
 | 
|---|
 | 137 |         int **([]),
 | 
|---|
 | 138 |         int **([10]),
 | 
|---|
 | 139 |         int * const *([]),
 | 
|---|
 | 140 |         int * const *([10]),
 | 
|---|
 | 141 |         int * const * const ([]),
 | 
|---|
 | 142 |         int * const * const ([10])
 | 
|---|
 | 143 |         );
 | 
|---|
| [51b73452] | 144 | 
 | 
|---|
 | 145 | int f(
 | 
|---|
| [a65d92e] | 146 |         int (),
 | 
|---|
 | 147 | 
 | 
|---|
 | 148 |         int *(),
 | 
|---|
 | 149 |         int **(),
 | 
|---|
 | 150 |         int * const *(),
 | 
|---|
 | 151 |         int * const * const (),
 | 
|---|
 | 152 | 
 | 
|---|
 | 153 |         int ([]),
 | 
|---|
 | 154 |         int ([10]),
 | 
|---|
 | 155 | 
 | 
|---|
 | 156 |         int *([]),
 | 
|---|
 | 157 |         int *([10]),
 | 
|---|
 | 158 |         int **([]),
 | 
|---|
 | 159 |         int **([10]),
 | 
|---|
 | 160 |         int * const *([]),
 | 
|---|
 | 161 |         int * const *([10]),
 | 
|---|
 | 162 |         int * const * const ([]),
 | 
|---|
 | 163 |         int * const * const ([10])
 | 
|---|
 | 164 |         ) {
 | 
|---|
| [51b73452] | 165 | }
 | 
|---|
 | 166 | 
 | 
|---|
 | 167 | typedef int T;
 | 
|---|
 | 168 | 
 | 
|---|
| [0b2961f] | 169 | int f( T (*f), T t ) {
 | 
|---|
| [a65d92e] | 170 |         T (T);
 | 
|---|
| [51b73452] | 171 | }
 | 
|---|
 | 172 | 
 | 
|---|
 | 173 | // errors
 | 
|---|
 | 174 | 
 | 
|---|
 | 175 | //int f()[] {}
 | 
|---|
 | 176 | //int (f[])() {}
 | 
|---|
 | 177 | //int f[]() {}
 | 
|---|
 | 178 | //int ((*f15())())[] {}
 | 
|---|
| [a65d92e] | 179 | 
 | 
|---|
 | 180 | // Local Variables: //
 | 
|---|
 | 181 | // tab-width: 4 //
 | 
|---|
| [5ead9f9] | 182 | // compile-command: "cfa functions.c" //
 | 
|---|
| [a65d92e] | 183 | // End: //
 | 
|---|