111
|
1 /* Miscellaneous OpenACC routine front end checking. */
|
|
2
|
|
3 /* Pragma context. */
|
|
4
|
|
5 struct PC
|
|
6 {
|
145
|
7 #pragma acc routine /* { dg-error ".#pragma acc routine. must be at file scope" } */
|
111
|
8 };
|
|
9
|
|
10 void PC1( /* { dg-bogus "variable or field .PC1. declared void" "TODO" { xfail c++ } } */
|
145
|
11 #pragma acc routine
|
111
|
12 /* { dg-error ".#pragma acc routine. must be at file scope" "" { target c } .-1 }
|
|
13 { dg-error ".#pragma. is not allowed here" "" { target c++ } .-2 } */
|
|
14 ) /* { dg-bogus "expected declaration specifiers or .\\.\\.\\.. before .\\). token" "TODO" { xfail c } } */
|
|
15 {
|
|
16 }
|
|
17
|
|
18 void PC2()
|
|
19 {
|
|
20 if (0)
|
145
|
21 #pragma acc routine /* { dg-error ".#pragma acc routine. must be at file scope" } */
|
111
|
22 ;
|
|
23 }
|
|
24
|
|
25 void PC3()
|
|
26 {
|
145
|
27 #pragma acc routine /* { dg-error ".#pragma acc routine. must be at file scope" } */
|
111
|
28 }
|
|
29
|
|
30
|
|
31 /* "( name )" syntax. */
|
|
32
|
|
33 #pragma acc routine ( /* { dg-error "expected (function name|unqualified-id) before end of line" } */
|
145
|
34 #pragma acc routine () /* { dg-error "expected (function name|unqualified-id) before .\\). token" } */
|
|
35 #pragma acc routine (+) /* { dg-error "expected (function name|unqualified-id) before .\\+. token" } */
|
|
36 #pragma acc routine (?) /* { dg-error "expected (function name|unqualified-id) before .\\?. token" } */
|
|
37 #pragma acc routine (:) /* { dg-error "expected (function name|unqualified-id) before .:. token" } */
|
|
38 #pragma acc routine (4) /* { dg-error "expected (function name|unqualified-id) before numeric constant" } */
|
111
|
39 #pragma acc routine ('4') /* { dg-error "expected (function name|unqualified-id) before .4." } */
|
145
|
40 #pragma acc routine ("4") /* { dg-error "expected (function name|unqualified-id) before string constant" } */
|
111
|
41 extern void R1(void);
|
|
42 extern void R2(void);
|
|
43 #pragma acc routine (R1, R2, R3) worker /* { dg-error "expected .\\). before .,. token" } */
|
|
44 #pragma acc routine (R1 R2 R3) worker /* { dg-error "expected .\\). before .R2." } */
|
|
45 #pragma acc routine (R1) worker
|
|
46 #pragma acc routine (R2) worker
|
|
47
|
|
48
|
|
49 /* "#pragma acc routine" not immediately followed by (a single) function
|
|
50 declaration or definition. */
|
|
51
|
145
|
52 #pragma acc routine /* { dg-error ".#pragma acc routine. not immediately followed by function declaration or definition" } */
|
111
|
53 int a;
|
|
54
|
145
|
55 #pragma acc routine /* { dg-error ".#pragma acc routine. not immediately followed by a single function declaration or definition" } */
|
111
|
56 void fn1 (void), fn1b (void);
|
|
57
|
145
|
58 #pragma acc routine /* { dg-error ".#pragma acc routine. not immediately followed by function declaration or definition" } */
|
111
|
59 int b, fn2 (void);
|
|
60
|
145
|
61 #pragma acc routine /* { dg-error ".#pragma acc routine. not immediately followed by function declaration or definition" } */
|
111
|
62 int b_, fn2_ (void), B_;
|
|
63
|
145
|
64 #pragma acc routine /* { dg-error ".#pragma acc routine. not immediately followed by a single function declaration or definition" } */
|
111
|
65 int fn3 (void), b2;
|
|
66
|
145
|
67 #pragma acc routine /* { dg-error ".#pragma acc routine. not immediately followed by function declaration or definition" } */
|
111
|
68 typedef struct c c;
|
|
69
|
145
|
70 #pragma acc routine /* { dg-error ".#pragma acc routine. not immediately followed by function declaration or definition" } */
|
111
|
71 struct d {} d;
|
|
72
|
145
|
73 #pragma acc routine /* { dg-error ".#pragma acc routine. not immediately followed by function declaration or definition" } */
|
|
74 #pragma acc routine /* { dg-error ".#pragma acc routine. not immediately followed by a single function declaration or definition" } */
|
111
|
75 void fn1_2 (void), fn1b_2 (void);
|
|
76
|
145
|
77 #pragma acc routine /* { dg-error ".#pragma acc routine. not immediately followed by function declaration or definition" } */
|
111
|
78 #pragma acc routine /* { dg-error ".#pragma acc routine. not immediately followed by function declaration or definition" } */
|
|
79 int b_2, fn2_2 (void);
|
|
80
|
145
|
81 #pragma acc routine /* { dg-error ".#pragma acc routine. not immediately followed by function declaration or definition" } */
|
|
82 #pragma acc routine /* { dg-error ".#pragma acc routine. not immediately followed by function declaration or definition" } */
|
111
|
83 int b_2_, fn2_2_ (void), B_2_;
|
|
84
|
145
|
85 #pragma acc routine /* { dg-error ".#pragma acc routine. not immediately followed by function declaration or definition" } */
|
|
86 #pragma acc routine /* { dg-error ".#pragma acc routine. not immediately followed by a single function declaration or definition" } */
|
111
|
87 int fn3_2 (void), b2_2;
|
|
88
|
145
|
89 #pragma acc routine /* { dg-error ".#pragma acc routine. not immediately followed by function declaration or definition" } */
|
|
90 #pragma acc routine /* { dg-error ".#pragma acc routine. not immediately followed by function declaration or definition" } */
|
111
|
91 typedef struct c_2 c_2;
|
|
92
|
145
|
93 #pragma acc routine /* { dg-error ".#pragma acc routine. not immediately followed by function declaration or definition" } */
|
|
94 #pragma acc routine /* { dg-error ".#pragma acc routine. not immediately followed by function declaration or definition" } */
|
111
|
95 struct d_2 {} d_2;
|
|
96
|
145
|
97 #pragma acc routine /* { dg-error ".#pragma acc routine. not immediately followed by function declaration or definition" } */
|
|
98 #pragma acc routine
|
111
|
99 int fn4 (void);
|
|
100
|
|
101 int fn5a (void);
|
|
102 int fn5b (void);
|
145
|
103 #pragma acc routine /* { dg-error ".#pragma acc routine. not immediately followed by function declaration or definition" } */
|
|
104 #pragma acc routine (fn5a)
|
|
105 #pragma acc routine (fn5b)
|
111
|
106 int fn5 (void);
|
|
107
|
145
|
108 #pragma acc routine /* { dg-error ".#pragma acc routine. not immediately followed by function declaration or definition" } */
|
|
109 #pragma acc routine (fn6a) /* { dg-error ".fn6a. has not been declared" } */
|
|
110 #pragma acc routine (fn6b) /* { dg-error ".fn6b. has not been declared" } */
|
111
|
111 int fn6 (void);
|
|
112
|
|
113 #ifdef __cplusplus
|
|
114
|
145
|
115 #pragma acc routine /* { dg-error ".#pragma acc routine. not immediately followed by function declaration or definition" "" { target c++ } } */
|
111
|
116 namespace f {}
|
|
117
|
|
118 namespace g {}
|
|
119
|
145
|
120 #pragma acc routine /* { dg-error ".#pragma acc routine. not immediately followed by function declaration or definition" "" { target c++ } } */
|
111
|
121 using namespace g;
|
|
122
|
145
|
123 #pragma acc routine (g) /* { dg-error ".g. does not refer to a function" "" { target c++ } } */
|
111
|
124
|
|
125 #endif /* __cplusplus */
|
|
126
|
145
|
127 #pragma acc routine (a) /* { dg-error ".a. does not refer to a function" } */
|
111
|
128
|
145
|
129 #pragma acc routine (c) /* { dg-error ".c. does not refer to a function" } */
|
111
|
130
|
|
131
|
|
132 /* Static assert. */
|
|
133
|
|
134 #pragma acc routine /* { dg-bogus ".#pragma acc routine. not immediately followed by function declaration or definition" "TODO" { xfail *-*-* } } */
|
|
135 #ifndef __cplusplus /* C */
|
|
136 _Static_assert(0, ""); /* { dg-error "static assertion failed" "" { target c } } */
|
|
137 #elif __cplusplus < 201103L /* C++98 */
|
|
138 /* C++98 doesn't support static_assert, so fake an error in combination, and as
|
|
139 expected with the "#pragma acc routine" above. */
|
|
140 int dummy_instead_of_static_assert;
|
|
141 #else /* C++ */
|
|
142 static_assert(0, ""); /* { dg-error "static assertion failed" "" { target c++11 } } */
|
|
143 #endif
|
|
144 void f_static_assert();
|
|
145 /* Check that we already recognized "f_static_assert" as an OpenACC routine. */
|
145
|
146 #pragma acc routine (f_static_assert) /* { dg-error ".#pragma acc routine. already applied to .\[void \]*f_static_assert" "TODO" { xfail *-*-* } } */
|
111
|
147
|
|
148
|
|
149 /* __extension__ usage. */
|
|
150
|
145
|
151 #pragma acc routine
|
111
|
152 __extension__ extern void ex1();
|
145
|
153 #pragma acc routine (ex1) worker /* { dg-error "has already been marked with an OpenACC 'routine' directive" } */
|
111
|
154
|
145
|
155 #pragma acc routine
|
111
|
156 __extension__ __extension__ __extension__ __extension__ __extension__ void ex2()
|
|
157 {
|
|
158 }
|
145
|
159 #pragma acc routine (ex2) worker /* { dg-error "has already been marked with an OpenACC 'routine' directive" } */
|
111
|
160
|
145
|
161 #pragma acc routine /* { dg-error ".#pragma acc routine. not immediately followed by function declaration or definition" } */
|
111
|
162 __extension__ int ex3;
|
145
|
163 #pragma acc routine (ex3) /* { dg-error ".ex3. does not refer to a function" } */
|
111
|
164
|
|
165
|
|
166 /* "#pragma acc routine" must be applied before. */
|
|
167
|
|
168 void Bar ();
|
|
169
|
|
170 void Foo ()
|
|
171 {
|
|
172 Bar ();
|
|
173 }
|
|
174
|
145
|
175 #pragma acc routine (Bar) // { dg-error ".#pragma acc routine. must be applied before use" }
|
111
|
176
|
|
177 #pragma acc routine (Foo) gang // { dg-error ".#pragma acc routine. must be applied before definition" }
|
|
178
|
145
|
179 #pragma acc routine (Baz) // { dg-error "not been declared" }
|
111
|
180
|
|
181
|
|
182 /* OpenACC declare. */
|
|
183
|
|
184 int vb1; /* { dg-error "directive for use" } */
|
|
185 extern int vb2; /* { dg-error "directive for use" } */
|
|
186 static int vb3; /* { dg-error "directive for use" } */
|
|
187
|
145
|
188 #pragma acc routine
|
111
|
189 int
|
|
190 func1 (int a)
|
|
191 {
|
|
192 vb1 = a + 1;
|
|
193 vb2 = vb1 + 1;
|
|
194 vb3 = vb2 + 1;
|
|
195
|
|
196 return vb3;
|
|
197 }
|
|
198
|
145
|
199 #pragma acc routine
|
111
|
200 int
|
|
201 func2 (int a)
|
|
202 {
|
|
203 extern int vb4; /* { dg-error "directive for use" } */
|
145
|
204 static int vb5;
|
111
|
205
|
|
206 vb4 = a + 1;
|
|
207 vb5 = vb4 + 1;
|
|
208
|
|
209 return vb5;
|
|
210 }
|
|
211
|
|
212 extern int vb6; /* { dg-error "clause used in" } */
|
|
213 #pragma acc declare link (vb6)
|
|
214 static int vb7; /* { dg-error "clause used in" } */
|
|
215 #pragma acc declare link (vb7)
|
|
216
|
145
|
217 #pragma acc routine
|
111
|
218 int
|
|
219 func3 (int a)
|
|
220 {
|
|
221 vb6 = a + 1;
|
|
222 vb7 = vb6 + 1;
|
|
223
|
|
224 return vb7;
|
|
225 }
|
|
226
|
|
227 int vb8;
|
|
228 #pragma acc declare create (vb8)
|
|
229 extern int vb9;
|
|
230 #pragma acc declare create (vb9)
|
|
231 static int vb10;
|
|
232 #pragma acc declare create (vb10)
|
|
233
|
145
|
234 #pragma acc routine
|
111
|
235 int
|
|
236 func4 (int a)
|
|
237 {
|
|
238 vb8 = a + 1;
|
|
239 vb9 = vb8 + 1;
|
|
240 vb10 = vb9 + 1;
|
|
241
|
|
242 return vb10;
|
|
243 }
|
|
244
|
|
245 int vb11;
|
|
246 #pragma acc declare device_resident (vb11)
|
|
247 extern int vb12;
|
|
248 #pragma acc declare device_resident (vb12)
|
|
249 extern int vb13;
|
|
250 #pragma acc declare device_resident (vb13)
|
|
251
|
145
|
252 #pragma acc routine
|
111
|
253 int
|
|
254 func5 (int a)
|
|
255 {
|
|
256 vb11 = a + 1;
|
|
257 vb12 = vb11 + 1;
|
|
258 vb13 = vb12 + 1;
|
|
259
|
|
260 return vb13;
|
|
261 }
|
|
262
|
145
|
263 #pragma acc routine
|
111
|
264 int
|
|
265 func6 (int a)
|
|
266 {
|
|
267 extern int vb14;
|
|
268 #pragma acc declare create (vb14)
|
|
269 static int vb15;
|
|
270 #pragma acc declare create (vb15)
|
|
271
|
|
272 vb14 = a + 1;
|
|
273 vb15 = vb14 + 1;
|
|
274
|
|
275 return vb15;
|
|
276 }
|