Debian Codegraph @

clang/test/SemaOpenACC/compute-construct-self-clause.c

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