1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182
|
// RUN: %clang_cc1 %s -fopenacc -verify
struct NotConvertible{} NC;
int getI();
void uses() {
int Var;
#pragma acc update async self(Var)
#pragma acc update wait self(Var)
#pragma acc update self(Var) device_type(host)
#pragma acc update if(true) self(Var)
#pragma acc update if_present self(Var)
#pragma acc update self(Var)
#pragma acc update host(Var)
#pragma acc update device(Var)
// expected-error@+2{{OpenACC clause 'if' may not follow a 'device_type' clause in a 'update' construct}}
// expected-note@+1{{active 'device_type' clause here}}
#pragma acc update self(Var) device_type(default) if(true)
// expected-error@+2{{OpenACC clause 'if_present' may not follow a 'device_type' clause in a 'update' construct}}
// expected-note@+1{{active 'device_type' clause here}}
#pragma acc update self(Var) device_type(multicore) if_present
// expected-error@+2{{OpenACC clause 'self' may not follow a 'device_type' clause in a 'update' construct}}
// expected-note@+1{{active 'device_type' clause here}}
#pragma acc update self(Var) device_type(nvidia) self(Var)
// expected-error@+2{{OpenACC clause 'host' may not follow a 'device_type' clause in a 'update' construct}}
// expected-note@+1{{active 'device_type' clause here}}
#pragma acc update self(Var) device_type(radeon) host(Var)
// expected-error@+2{{OpenACC clause 'device' may not follow a 'device_type' clause in a 'update' construct}}
// expected-note@+1{{active 'device_type' clause here}}
#pragma acc update self(Var) device_type(multicore) device(Var)
// These 2 are OK.
#pragma acc update self(Var) device_type(default) async
#pragma acc update self(Var) device_type(nvidia) wait
// Unless otherwise specified, we assume 'device_type' can happen after itself.
#pragma acc update self(Var) device_type(acc_device_nvidia) device_type(multicore)
// These diagnose because there isn't at least 1 of 'self', 'host', or
// 'device'.
// expected-error@+1{{OpenACC 'update' construct must have at least one 'device', 'host', or 'self' clause}}
#pragma acc update async
// expected-error@+1{{OpenACC 'update' construct must have at least one 'device', 'host', or 'self' clause}}
#pragma acc update wait
// expected-error@+1{{OpenACC 'update' construct must have at least one 'device', 'host', or 'self' clause}}
#pragma acc update device_type(host)
// expected-error@+1{{OpenACC 'update' construct must have at least one 'device', 'host', or 'self' clause}}
#pragma acc update if(true)
// expected-error@+1{{OpenACC 'update' construct must have at least one 'device', 'host', or 'self' clause}}
#pragma acc update if_present
// expected-error@+1{{value of type 'struct NotConvertible' is not contextually convertible to 'bool'}}
#pragma acc update self(Var) if (NC) device_type(radeon)
// expected-error@+2{{OpenACC 'if' clause cannot appear more than once on a 'update' directive}}
// expected-note@+1{{previous 'if' clause is here}}
#pragma acc update self(Var) if(true) if (false)
// Cannot be the body of an 'if', 'while', 'do', 'switch', or
// 'label'.
// expected-error@+2{{OpenACC 'update' construct may not appear in place of the statement following an if statement}}
if (true)
#pragma acc update device(Var)
// expected-error@+2{{OpenACC 'update' construct may not appear in place of the statement following a while statement}}
while (true)
#pragma acc update device(Var)
// expected-error@+2{{OpenACC 'update' construct may not appear in place of the statement following a do statement}}
do
#pragma acc update device(Var)
while (true);
// expected-error@+2{{OpenACC 'update' construct may not appear in place of the statement following a switch statement}}
switch(Var)
#pragma acc update device(Var)
// expected-error@+2{{OpenACC 'update' construct may not appear in place of the statement following a label statement}}
LABEL:
#pragma acc update device(Var)
// For loops are OK.
for (;;)
#pragma acc update device(Var)
// Checking for 'async', which requires an 'int' expression.
#pragma acc update self(Var) async
#pragma acc update self(Var) async(getI())
// expected-error@+2{{expected ')'}}
// expected-note@+1{{to match this '('}}
#pragma acc update self(Var) async(getI(), getI())
// expected-error@+2{{OpenACC 'async' clause cannot appear more than once on a 'update' directive}}
// expected-note@+1{{previous 'async' clause is here}}
#pragma acc update self(Var) async(getI()) async(getI())
// expected-error@+1{{OpenACC clause 'async' requires expression of integer type ('struct NotConvertible' invalid)}}
#pragma acc update self(Var) async(NC)
// Checking for 'wait', which has a complicated set arguments.
#pragma acc update self(Var) wait
#pragma acc update self(Var) wait(getI(), getI())
#pragma acc update self(Var) wait(devnum: getI(): getI())
#pragma acc update self(Var) wait(devnum: getI(): queues: getI(), getI())
// expected-error@+1{{OpenACC clause 'wait' requires expression of integer type ('struct NotConvertible' invalid)}}
#pragma acc update self(Var) wait(devnum:NC : 5)
// expected-error@+1{{OpenACC clause 'wait' requires expression of integer type ('struct NotConvertible' invalid)}}
#pragma acc update self(Var) wait(devnum:5 : NC)
int arr[5];
// expected-error@+3{{OpenACC clause 'wait' requires expression of integer type ('int[5]' invalid)}}
// expected-error@+2{{OpenACC clause 'wait' requires expression of integer type ('int[5]' invalid)}}
// expected-error@+1{{OpenACC clause 'wait' requires expression of integer type ('struct NotConvertible' invalid)}}
#pragma acc update self(Var) wait(devnum:arr : queues: arr, NC, 5)
}
struct SomeS {
int Array[5];
int MemberOfComp;
};
template<typename I, typename T>
void varlist_restrictions_templ() {
I iArray[5];
T Single;
T Array[5];
// Members of a subarray of struct or class type may not appear, but others
// are permitted to.
#pragma acc update self(iArray[0:1])
#pragma acc update host(iArray[0:1])
#pragma acc update device(iArray[0:1])
#pragma acc update self(Array[0:1])
#pragma acc update host(Array[0:1])
#pragma acc update device(Array[0:1])
// expected-error@+1{{OpenACC sub-array is not allowed here}}
#pragma acc update self(Array[0:1].MemberOfComp)
// expected-error@+1{{OpenACC sub-array is not allowed here}}
#pragma acc update host(Array[0:1].MemberOfComp)
// expected-error@+1{{OpenACC sub-array is not allowed here}}
#pragma acc update device(Array[0:1].MemberOfComp)
}
void varlist_restrictions() {
varlist_restrictions_templ<int, SomeS>();// expected-note{{in instantiation of}}
int iArray[5];
SomeS Single;
SomeS Array[5];
int LocalInt;
int *LocalPtr;
#pragma acc update self(LocalInt, LocalPtr, Single)
#pragma acc update host(LocalInt, LocalPtr, Single)
#pragma acc update device(LocalInt, LocalPtr, Single)
#pragma acc update self(Single.MemberOfComp)
#pragma acc update host(Single.MemberOfComp)
#pragma acc update device(Single.MemberOfComp)
#pragma acc update self(Single.Array[0:1])
#pragma acc update host(Single.Array[0:1])
#pragma acc update device(Single.Array[0:1])
// Members of a subarray of struct or class type may not appear, but others
// are permitted to.
#pragma acc update self(iArray[0:1])
#pragma acc update host(iArray[0:1])
#pragma acc update device(iArray[0:1])
#pragma acc update self(Array[0:1])
#pragma acc update host(Array[0:1])
#pragma acc update device(Array[0:1])
// expected-error@+1{{OpenACC sub-array is not allowed here}}
#pragma acc update self(Array[0:1].MemberOfComp)
// expected-error@+1{{OpenACC sub-array is not allowed here}}
#pragma acc update host(Array[0:1].MemberOfComp)
// expected-error@+1{{OpenACC sub-array is not allowed here}}
#pragma acc update device(Array[0:1].MemberOfComp)
}
|