1 // RUN: %clang_cc1 %s -fopenacc -verify
3 void BoolExpr(int *I
, float *F
) {
4 typedef struct {} SomeStruct
;
6 // expected-error@+1{{expected expression}}
7 #pragma acc parallel loop self (struct C f())
8 for (unsigned i
= 0; i
< 5; ++i
);
10 // expected-error@+1{{unexpected type name 'SomeStruct': expected expression}}
11 #pragma acc serial loop self (SomeStruct)
12 for (unsigned i
= 0; i
< 5; ++i
);
14 // expected-error@+1{{unexpected type name 'SomeStruct': expected expression}}
15 #pragma acc kernels loop self (SomeStruct())
16 for (unsigned i
= 0; i
< 5; ++i
);
19 // expected-error@+1{{statement requires expression of scalar type ('SomeStruct' invalid)}}
20 #pragma acc parallel loop self (S)
21 for (unsigned i
= 0; i
< 5; ++i
);
23 #pragma acc parallel loop self (I)
24 for (unsigned i
= 0; i
< 5; ++i
);
26 #pragma acc serial loop self (F)
27 for (unsigned i
= 0; i
< 5; ++i
);
29 #pragma acc kernels loop self (*I < *F)
30 for (unsigned i
= 0; i
< 5; ++i
);
33 void WarnMaybeNotUsed(int val1
, int val2
) {
35 // expected-warning@+2{{OpenACC construct 'self' has no effect when an 'if' clause evaluates to true}}
36 // expected-note@+1{{previous clause is here}}
37 #pragma acc parallel loop self if(val1)
38 for (unsigned i
= 0; i
< 5; ++i
);
40 // expected-warning@+2{{OpenACC construct 'self' has no effect when an 'if' clause evaluates to true}}
41 // expected-note@+1{{previous clause is here}}
42 #pragma acc serial loop self(val1) if(val1)
43 for (unsigned i
= 0; i
< 5; ++i
);
45 // expected-warning@+2{{OpenACC construct 'self' has no effect when an 'if' clause evaluates to true}}
46 // expected-note@+1{{previous clause is here}}
47 #pragma acc kernels loop if(val1) self
48 for (unsigned i
= 0; i
< 5; ++i
);
50 // expected-warning@+2{{OpenACC construct 'self' has no effect when an 'if' clause evaluates to true}}
51 // expected-note@+1{{previous clause is here}}
52 #pragma acc parallel loop if(val1) self(val2)
53 for (unsigned i
= 0; i
< 5; ++i
);
55 // The below don't warn because one side or the other has an error, thus is
56 // not added to the AST.
58 // expected-error@+1{{use of undeclared identifier 'invalid'}}
59 #pragma acc serial loop self if(invalid)
60 for (unsigned i
= 0; i
< 5; ++i
);
62 // expected-error@+1{{use of undeclared identifier 'invalid'}}
63 #pragma acc kernels loop self(invalid) if(val1)
64 for (unsigned i
= 0; i
< 5; ++i
);
66 // expected-error@+2{{expected expression}}
67 // expected-error@+1{{use of undeclared identifier 'invalid'}}
68 #pragma acc parallel loop self() if(invalid)
69 for (unsigned i
= 0; i
< 5; ++i
);
71 // expected-error@+1{{use of undeclared identifier 'invalid'}}
72 #pragma acc serial loop if(invalid) self
73 for (unsigned i
= 0; i
< 5; ++i
);
75 // expected-error@+1{{use of undeclared identifier 'invalid'}}
76 #pragma acc kernels loop if(val2) self(invalid)
77 for (unsigned i
= 0; i
< 5; ++i
);
79 // expected-error@+1{{use of undeclared identifier 'invalid'}}
80 #pragma acc parallel loop if(invalid) self(val1)
81 for (unsigned i
= 0; i
< 5; ++i
);
83 // expected-error@+1{{OpenACC 'self' clause is not valid on 'loop' directive}}
85 for(int i
= 5; i
< 10;++i
);