1 // RUN: %clang_cc1 %s -fopenacc -verify
3 struct CompositeOfScalars
{
13 struct CompositeHasComposite
{
21 struct CompositeOfScalars COS
; // #COS_FIELD
24 // All of the type checking is done for compute and loop constructs, so only check the basics + the parts that are combined specific.
25 void uses(unsigned Parm
) {
26 struct CompositeOfScalars CoS
;
27 struct CompositeHasComposite ChC
;
32 // legal on all 3 kinds of combined constructs
33 #pragma acc parallel loop reduction(+:Parm)
34 for(int i
= 0; i
< 5; ++i
);
36 #pragma acc serial loop reduction(&: CoS, I, F)
37 for(int i
= 0; i
< 5; ++i
);
39 #pragma acc kernels loop reduction(min: CoS, Array[I], Array[0:I])
40 for(int i
= 0; i
< 5; ++i
);
42 // expected-error@+2{{OpenACC 'reduction' composite variable must not have non-scalar field}}
43 // expected-note@#COS_FIELD{{invalid field is here}}
44 #pragma acc parallel loop reduction(&: ChC)
45 for(int i
= 0; i
< 5; ++i
);
47 #pragma acc kernels loop reduction(+:Parm) num_gangs(I)
48 for(int i
= 0; i
< 5; ++i
);
49 // expected-error@+2{{OpenACC 'num_gangs' clause with more than 1 argument may not appear on a 'parallel loop' construct with a 'reduction' clause}}
50 // expected-note@+1{{previous clause is here}}
51 #pragma acc parallel loop reduction(+:Parm) num_gangs(I, I)
52 for(int i
= 0; i
< 5; ++i
);
54 #pragma acc kernels loop num_gangs(I) reduction(+:Parm)
55 for(int i
= 0; i
< 5; ++i
);
56 // expected-error@+2{{OpenACC 'reduction' clause may not appear on a 'parallel loop' construct with a 'num_gangs' clause with more than 1 argument}}
57 // expected-note@+1{{previous clause is here}}
58 #pragma acc parallel loop num_gangs(I, I) reduction(+:Parm)
59 for(int i
= 0; i
< 5; ++i
);
61 // Reduction cannot appear on a loop with a 'gang' of dim>1.
62 #pragma acc parallel loop gang(dim:1) reduction(+:Parm)
63 for(int i
= 0; i
< 5; ++i
);
64 // expected-error@+2{{OpenACC 'reduction' clause cannot appear on the same 'parallel loop' construct as a 'gang' clause with a 'dim' value greater than 1}}
65 // expected-note@+1{{previous clause is here}}
66 #pragma acc parallel loop gang(dim:2) reduction(+:Parm)
67 for(int i
= 0; i
< 5; ++i
);
68 #pragma acc parallel loop reduction(+:Parm) gang(dim:1)
69 for(int i
= 0; i
< 5; ++i
);
70 // expected-error@+2{{OpenACC 'gang' clause with a 'dim' value greater than 1 cannot appear on the same 'parallel loop' construct as a 'reduction' clause}}
71 // expected-note@+1{{previous clause is here}}
72 #pragma acc parallel loop reduction(+:Parm) gang(dim:2)
73 for(int i
= 0; i
< 5; ++i
);
75 // Reduction cannot appear on a loop with a gang and a num_gangs with >1
77 #pragma acc kernels loop num_gangs(I) reduction(+:Parm) gang
78 for(int i
= 0; i
< 5; ++i
);
79 #pragma acc kernels loop num_gangs(I) gang reduction(+:Parm)
80 for(int i
= 0; i
< 5; ++i
);
81 #pragma acc kernels loop reduction(+:Parm) num_gangs(I) gang
82 for(int i
= 0; i
< 5; ++i
);
83 #pragma acc kernels loop reduction(+:Parm) gang num_gangs(I)
84 for(int i
= 0; i
< 5; ++i
);
85 #pragma acc kernels loop gang num_gangs(I) reduction(+:Parm)
86 for(int i
= 0; i
< 5; ++i
);
87 #pragma acc kernels loop gang reduction(+:Parm) num_gangs(I)
88 for(int i
= 0; i
< 5; ++i
);
90 // expected-error@+2{{OpenACC 'reduction' clause may not appear on a 'parallel loop' construct with a 'num_gangs' clause with more than 1 argument}}
91 // expected-note@+1{{previous clause is here}}
92 #pragma acc parallel loop num_gangs(I, I) reduction(+:Parm) gang
93 for(int i
= 0; i
< 5; ++i
);
94 // expected-error@+3{{OpenACC 'reduction' clause cannot appear on the same 'parallel loop' construct as a 'gang' clause and a 'num_gangs' clause with more than one argument}}
95 // expected-note@+2{{previous clause is here}}
96 // expected-note@+1{{previous clause is here}}
97 #pragma acc parallel loop num_gangs(I, I) gang reduction(+:Parm)
98 for(int i
= 0; i
< 5; ++i
);
99 // expected-error@+2{{OpenACC 'num_gangs' clause with more than 1 argument may not appear on a 'parallel loop' construct with a 'reduction' clause}}
100 // expected-note@+1{{previous clause is here}}
101 #pragma acc parallel loop reduction(+:Parm) num_gangs(I, I) gang
102 for(int i
= 0; i
< 5; ++i
);
103 // expected-error@+3{{OpenACC 'reduction' clause cannot appear on the same 'parallel loop' construct as a 'gang' clause and a 'num_gangs' clause with more than one argument}}
104 // expected-note@+2{{previous clause is here}}
105 // expected-note@+1{{previous clause is here}}
106 #pragma acc parallel loop reduction(+:Parm) gang num_gangs(I, I)
107 for(int i
= 0; i
< 5; ++i
);
108 // expected-error@+3{{OpenACC 'reduction' clause cannot appear on the same 'parallel loop' construct as a 'gang' clause and a 'num_gangs' clause with more than one argument}}
109 // expected-note@+2{{previous clause is here}}
110 // expected-note@+1{{previous clause is here}}
111 #pragma acc parallel loop gang num_gangs(I, I) reduction(+:Parm)
112 for(int i
= 0; i
< 5; ++i
);
113 // expected-error@+3{{OpenACC 'reduction' clause cannot appear on the same 'parallel loop' construct as a 'gang' clause and a 'num_gangs' clause with more than one argument}}
114 // expected-note@+2{{previous clause is here}}
115 // expected-note@+1{{previous clause is here}}
116 #pragma acc parallel loop gang reduction(+:Parm) num_gangs(I, I)
117 for(int i
= 0; i
< 5; ++i
);
119 #pragma acc parallel loop num_gangs(I) reduction(+:Parm) gang
120 for(int i
= 0; i
< 5; ++i
);
121 #pragma acc parallel loop num_gangs(I) gang reduction(+:Parm)
122 for(int i
= 0; i
< 5; ++i
);
123 #pragma acc parallel loop reduction(+:Parm) num_gangs(I) gang
124 for(int i
= 0; i
< 5; ++i
);
125 #pragma acc parallel loop reduction(+:Parm) gang num_gangs(I)
126 for(int i
= 0; i
< 5; ++i
);
127 #pragma acc parallel loop gang num_gangs(I) reduction(+:Parm)
128 for(int i
= 0; i
< 5; ++i
);
129 #pragma acc parallel loop gang reduction(+:Parm) num_gangs(I)
130 for(int i
= 0; i
< 5; ++i
);
132 #pragma acc parallel loop reduction(+:I)
133 for(int i
= 0; i
< 5; ++i
) {
134 // expected-error@+2{{OpenACC 'reduction' variable must have the same operator in all nested constructs (& vs +)}}
135 // expected-note@-3{{previous clause is here}}
136 #pragma acc loop reduction(&:I)
137 for(int i
= 0; i
< 5; ++i
);
139 #pragma acc parallel loop reduction(+:I)
140 for(int i
= 0; i
< 5; ++i
) {
141 // expected-error@+2{{OpenACC 'reduction' variable must have the same operator in all nested constructs (& vs +)}}
142 // expected-note@-3{{previous clause is here}}
143 #pragma acc parallel reduction(&:I)
144 for(int i
= 0; i
< 5; ++i
);
147 #pragma acc parallel loop reduction(+:I)
148 for(int i
= 0; i
< 5; ++i
) {
149 // expected-error@+2{{OpenACC 'reduction' variable must have the same operator in all nested constructs (& vs +)}}
150 // expected-note@-3{{previous clause is here}}
151 #pragma acc parallel loop reduction(&:I)
152 for(int i
= 0; i
< 5; ++i
);
154 #pragma acc loop reduction(+:I)
155 for(int i
= 0; i
< 5; ++i
) {
156 // expected-error@+2{{OpenACC 'reduction' variable must have the same operator in all nested constructs (& vs +)}}
157 // expected-note@-3{{previous clause is here}}
158 #pragma acc parallel loop reduction(&:I)
159 for(int i
= 0; i
< 5; ++i
);
162 #pragma acc parallel reduction(+:I)
163 for(int i
= 0; i
< 5; ++i
) {
164 // expected-error@+2{{OpenACC 'reduction' variable must have the same operator in all nested constructs (& vs +)}}
165 // expected-note@-3{{previous clause is here}}
166 #pragma acc parallel loop reduction(&:I)
167 for(int i
= 0; i
< 5; ++i
);