1a15b685cSErich Keane // RUN: %clang_cc1 %s -fopenacc -verify 2a15b685cSErich Keane 3a15b685cSErich Keane struct CompositeOfScalars { 4a15b685cSErich Keane int I; 5a15b685cSErich Keane float F; 6a15b685cSErich Keane short J; 7a15b685cSErich Keane char C; 8a15b685cSErich Keane double D; 9a15b685cSErich Keane _Complex float CF; 10a15b685cSErich Keane _Complex double CD; 11a15b685cSErich Keane }; 12a15b685cSErich Keane 13a15b685cSErich Keane struct CompositeHasComposite { 14a15b685cSErich Keane int I; 15a15b685cSErich Keane float F; 16a15b685cSErich Keane short J; 17a15b685cSErich Keane char C; 18a15b685cSErich Keane double D; 19a15b685cSErich Keane _Complex float CF; 20a15b685cSErich Keane _Complex double CD; 21a15b685cSErich Keane struct CompositeOfScalars COS; // #COS_FIELD 22a15b685cSErich Keane }; 23a15b685cSErich Keane 24a15b685cSErich Keane void uses(unsigned Parm) { 25a15b685cSErich Keane float Var; 26a15b685cSErich Keane int IVar; 27a15b685cSErich Keane 28a15b685cSErich Keane #pragma acc parallel reduction(+:Parm) 29a15b685cSErich Keane while (1); 30a15b685cSErich Keane #pragma acc serial reduction(+:Parm) 31a15b685cSErich Keane while (1); 32a15b685cSErich Keane // expected-error@+1{{OpenACC 'reduction' clause is not valid on 'kernels' directive}} 33a15b685cSErich Keane #pragma acc kernels reduction(+:Parm) 34a15b685cSErich Keane while (1); 35a15b685cSErich Keane 36a15b685cSErich Keane // On a 'parallel', 'num_gangs' cannot have >1 args. num_gangs not valid on 37a15b685cSErich Keane // 'serial', but 'reduction' not valid on 'kernels', other combos cannot be 38a15b685cSErich Keane // tested. 39a15b685cSErich Keane #pragma acc parallel reduction(+:Parm) num_gangs(IVar) 40a15b685cSErich Keane while (1); 41a15b685cSErich Keane #pragma acc parallel num_gangs(IVar) reduction(+:Var) 42a15b685cSErich Keane while (1); 43a15b685cSErich Keane 44*7d89ebfdSerichkeane // expected-error@+2{{OpenACC 'num_gangs' clause with more than 1 argument may not appear on a 'parallel' construct with a 'reduction' clause}} 45a15b685cSErich Keane // expected-note@+1{{previous clause is here}} 46a15b685cSErich Keane #pragma acc parallel reduction(+:Parm) num_gangs(Parm, IVar) 47a15b685cSErich Keane while (1); 48a15b685cSErich Keane 49*7d89ebfdSerichkeane // expected-error@+2{{OpenACC 'reduction' clause may not appear on a 'parallel' construct with a 'num_gangs' clause with more than 1 argument}} 50a15b685cSErich Keane // expected-note@+1{{previous clause is here}} 51a15b685cSErich Keane #pragma acc parallel num_gangs(Parm, IVar) reduction(+:Var) 52a15b685cSErich Keane while (1); 53a15b685cSErich Keane 54a15b685cSErich Keane #pragma acc parallel reduction(+:Parm) reduction(+:Parm) 55a15b685cSErich Keane while (1); 56a15b685cSErich Keane 57a15b685cSErich Keane struct CompositeOfScalars CoS; 58a15b685cSErich Keane struct CompositeOfScalars *CoSPtr; 59a15b685cSErich Keane struct CompositeHasComposite ChC; 60a15b685cSErich Keane struct CompositeHasComposite *ChCPtr; 61a15b685cSErich Keane 62a15b685cSErich Keane int I; 63a15b685cSErich Keane float F; 64a15b685cSErich Keane int Array[5]; 65a15b685cSErich Keane 66a15b685cSErich Keane // Vars in a reduction must be a scalar or a composite of scalars. 67a15b685cSErich Keane #pragma acc parallel reduction(&: CoS, I, F) 68a15b685cSErich Keane while (1); 69a15b685cSErich Keane // expected-error@+2{{OpenACC 'reduction' composite variable must not have non-scalar field}} 70a15b685cSErich Keane // expected-note@#COS_FIELD{{invalid field is here}} 71a15b685cSErich Keane #pragma acc parallel reduction(&: ChC) 72a15b685cSErich Keane while (1); 73a15b685cSErich Keane // expected-error@+1{{OpenACC 'reduction' variable must be of scalar type, sub-array, or a composite of scalar types; type is 'int[5]'}} 74a15b685cSErich Keane #pragma acc parallel reduction(&: Array) 75a15b685cSErich Keane while (1); 76a15b685cSErich Keane 77a15b685cSErich Keane #pragma acc parallel reduction(&: CoS, Array[I], Array[0:I]) 78a15b685cSErich Keane while (1); 79a15b685cSErich Keane 80a15b685cSErich Keane // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, or composite variable member}} 81a15b685cSErich Keane #pragma acc parallel reduction(&: CoS.I) 82a15b685cSErich Keane while (1); 83a15b685cSErich Keane 84a15b685cSErich Keane // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, or composite variable member}} 85a15b685cSErich Keane #pragma acc parallel reduction(&: CoSPtr->I) 86a15b685cSErich Keane 87a15b685cSErich Keane while (1); 88a15b685cSErich Keane // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, or composite variable member}} 89a15b685cSErich Keane #pragma acc parallel reduction(&: ChC.COS) 90a15b685cSErich Keane while (1); 91a15b685cSErich Keane 92a15b685cSErich Keane // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, or composite variable member}} 93a15b685cSErich Keane #pragma acc parallel reduction(&: ChCPtr->COS) 94a15b685cSErich Keane while (1); 95a15b685cSErich Keane } 96a15b685cSErich Keane 97a15b685cSErich Keane template<typename T, typename U, typename V> 98a15b685cSErich Keane void TemplUses(T Parm, U CoS, V ChC) { 99a15b685cSErich Keane T Var; 100a15b685cSErich Keane U *CoSPtr; 101a15b685cSErich Keane V *ChCPtr; 102a15b685cSErich Keane 103a15b685cSErich Keane #pragma acc parallel reduction(+:Parm) 104a15b685cSErich Keane while (1); 105a15b685cSErich Keane #pragma acc serial reduction(+:Parm) 106a15b685cSErich Keane while (1); 107a15b685cSErich Keane // expected-error@+1{{OpenACC 'reduction' clause is not valid on 'kernels' directive}} 108a15b685cSErich Keane #pragma acc kernels reduction(+:Parm) 109a15b685cSErich Keane while (1); 110a15b685cSErich Keane 111a15b685cSErich Keane // On a 'parallel', 'num_gangs' cannot have >1 args. num_gangs not valid on 112a15b685cSErich Keane // 'serial', but 'reduction' not valid on 'kernels', other combos cannot be 113a15b685cSErich Keane // tested. 114a15b685cSErich Keane #pragma acc parallel reduction(+:Parm) num_gangs(Var) 115a15b685cSErich Keane while (1); 116a15b685cSErich Keane #pragma acc parallel num_gangs(Var) reduction(+:Var) 117a15b685cSErich Keane while (1); 118a15b685cSErich Keane 119*7d89ebfdSerichkeane // expected-error@+2{{OpenACC 'num_gangs' clause with more than 1 argument may not appear on a 'parallel' construct with a 'reduction' clause}} 120a15b685cSErich Keane // expected-note@+1{{previous clause is here}} 121a15b685cSErich Keane #pragma acc parallel reduction(+:Parm) num_gangs(Parm, Var) 122a15b685cSErich Keane while (1); 123a15b685cSErich Keane 124*7d89ebfdSerichkeane // expected-error@+2{{OpenACC 'reduction' clause may not appear on a 'parallel' construct with a 'num_gangs' clause with more than 1 argument}} 125a15b685cSErich Keane // expected-note@+1{{previous clause is here}} 126a15b685cSErich Keane #pragma acc parallel num_gangs(Parm, Var) reduction(+:Var) 127a15b685cSErich Keane while (1); 128a15b685cSErich Keane 129a15b685cSErich Keane #pragma acc parallel reduction(+:Parm) reduction(+:Parm) 130a15b685cSErich Keane while (1); 131a15b685cSErich Keane 132a15b685cSErich Keane int NonDep; 133a15b685cSErich Keane int NonDepArray[5]; 134a15b685cSErich Keane T Array[5]; 135a15b685cSErich Keane 136a15b685cSErich Keane // Vars in a reduction must be a scalar or a composite of scalars. 137a15b685cSErich Keane #pragma acc parallel reduction(&: CoS, Var, Parm) 138a15b685cSErich Keane while (1); 139a15b685cSErich Keane // expected-error@+2{{OpenACC 'reduction' composite variable must not have non-scalar field}} 140a15b685cSErich Keane // expected-note@#COS_FIELD{{invalid field is here}} 141a15b685cSErich Keane #pragma acc parallel reduction(&: ChC) 142a15b685cSErich Keane while (1); 143a15b685cSErich Keane // expected-error@+1{{OpenACC 'reduction' variable must be of scalar type, sub-array, or a composite of scalar types; type is 'int[5]'}} 144a15b685cSErich Keane #pragma acc parallel reduction(&: Array) 145a15b685cSErich Keane while (1); 146a15b685cSErich Keane // expected-error@+1{{OpenACC 'reduction' variable must be of scalar type, sub-array, or a composite of scalar types; type is 'int[5]'}} 147a15b685cSErich Keane #pragma acc parallel reduction(&: NonDepArray) 148a15b685cSErich Keane while (1); 149a15b685cSErich Keane 150a15b685cSErich Keane #pragma acc parallel reduction(&: CoS, Array[Var], Array[0:Var]) 151a15b685cSErich Keane while (1); 152a15b685cSErich Keane 153a15b685cSErich Keane // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, or composite variable member}} 154a15b685cSErich Keane #pragma acc parallel reduction(&: CoS.I) 155a15b685cSErich Keane while (1); 156a15b685cSErich Keane 157a15b685cSErich Keane // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, or composite variable member}} 158a15b685cSErich Keane #pragma acc parallel reduction(&: CoSPtr->I) 159a15b685cSErich Keane 160a15b685cSErich Keane while (1); 161a15b685cSErich Keane // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, or composite variable member}} 162a15b685cSErich Keane #pragma acc parallel reduction(&: ChC.COS) 163a15b685cSErich Keane while (1); 164a15b685cSErich Keane 165a15b685cSErich Keane // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, or composite variable member}} 166a15b685cSErich Keane #pragma acc parallel reduction(&: ChCPtr->COS) 167a15b685cSErich Keane while (1); 168a15b685cSErich Keane } 169a15b685cSErich Keane 170a15b685cSErich Keane void inst() { 171a15b685cSErich Keane CompositeOfScalars CoS; 172a15b685cSErich Keane CompositeHasComposite ChC; 173a15b685cSErich Keane // expected-note@+1{{in instantiation of function template specialization}} 174a15b685cSErich Keane TemplUses(5, CoS, ChC); 175a15b685cSErich Keane } 176