diff options
author | NAKAMURA Takumi <geek4civic@gmail.com> | 2025-01-09 18:49:54 +0900 |
---|---|---|
committer | NAKAMURA Takumi <geek4civic@gmail.com> | 2025-01-09 18:49:54 +0900 |
commit | e2810c9a248f4c7fbfae84bb32b6f7e01027458b (patch) | |
tree | ae0b02a8491b969a1cee94ea16ffe42c559143c5 /clang/test/SemaOpenACC/update-construct.cpp | |
parent | fa04eb4af95c1ca7377279728cb004bcd2324d01 (diff) | |
parent | bdcf47e4bcb92889665825654bb80a8bbe30379e (diff) | |
download | llvm-users/chapuni/cov/single/switch.zip llvm-users/chapuni/cov/single/switch.tar.gz llvm-users/chapuni/cov/single/switch.tar.bz2 |
Merge branch 'users/chapuni/cov/single/base' into users/chapuni/cov/single/switchusers/chapuni/cov/single/switch
Diffstat (limited to 'clang/test/SemaOpenACC/update-construct.cpp')
-rw-r--r-- | clang/test/SemaOpenACC/update-construct.cpp | 167 |
1 files changed, 167 insertions, 0 deletions
diff --git a/clang/test/SemaOpenACC/update-construct.cpp b/clang/test/SemaOpenACC/update-construct.cpp new file mode 100644 index 0000000..2abd7a3 --- /dev/null +++ b/clang/test/SemaOpenACC/update-construct.cpp @@ -0,0 +1,167 @@ +// 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(I) +#pragma acc update if(true) self(Var) +#pragma acc update if_present self(Var) +#pragma acc update self(Var) + // expected-warning@+1{{OpenACC clause 'host' not yet implemented}} +#pragma acc update host(Var) + // expected-warning@+1{{OpenACC clause 'device' not yet implemented}} +#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{{previous clause is here}} +#pragma acc update self(Var) device_type(I) if(true) + // expected-error@+2{{OpenACC clause 'if_present' may not follow a 'device_type' clause in a 'update' construct}} + // expected-note@+1{{previous clause is here}} +#pragma acc update self(Var) device_type(I) if_present + // expected-error@+2{{OpenACC clause 'self' may not follow a 'device_type' clause in a 'update' construct}} + // expected-note@+1{{previous clause is here}} +#pragma acc update device_type(I) self(Var) + // expected-error@+2{{OpenACC clause 'host' may not follow a 'device_type' clause in a 'update' construct}} + // expected-note@+1{{previous clause is here}} +#pragma acc update device_type(I) host(Var) + // expected-error@+2{{OpenACC clause 'device' may not follow a 'device_type' clause in a 'update' construct}} + // expected-note@+1{{previous clause is here}} +#pragma acc update device_type(I) device(Var) + // These 2 are OK. +#pragma acc update self(Var) device_type(I) async +#pragma acc update self(Var) device_type(I) wait + // Unless otherwise specified, we assume 'device_type' can happen after itself. +#pragma acc update self(Var) device_type(I) device_type(I) + + // TODO: OpenACC: These should diagnose because there isn't at least 1 of + // 'self', 'host', or 'device'. +#pragma acc update async +#pragma acc update wait +#pragma acc update device_type(I) +#pragma acc update if(true) +#pragma acc update if_present + + // expected-error@+1{{value of type 'struct NotConvertible' is not contextually convertible to 'bool'}} +#pragma acc update if (NC) device_type(I) + + // expected-error@+2{{OpenACC 'if' clause cannot appear more than once on a 'update' directive}} + // expected-note@+1{{previous clause is here}} +#pragma acc update if(true) if (false) + + // TODO: OpenACC: There is restrictions on the contents of a 'varlist', so + // those should be checked here too. + + // Cannot be the body of an 'if', 'while', 'do', 'switch', or + // 'label'. + // expected-error@+3{{OpenACC 'update' construct may not appear in place of the statement following an if statement}} + if (true) + // expected-warning@+1{{OpenACC clause 'device' not yet implemented}} +#pragma acc update device(Var) + + // expected-error@+3{{OpenACC 'update' construct may not appear in place of the statement following a while statement}} + while (true) + // expected-warning@+1{{OpenACC clause 'device' not yet implemented}} +#pragma acc update device(Var) + + // expected-error@+3{{OpenACC 'update' construct may not appear in place of the statement following a do statement}} + do + // expected-warning@+1{{OpenACC clause 'device' not yet implemented}} +#pragma acc update device(Var) + while (true); + + // expected-error@+3{{OpenACC 'update' construct may not appear in place of the statement following a switch statement}} + switch(Var) + // expected-warning@+1{{OpenACC clause 'device' not yet implemented}} +#pragma acc update device(Var) + + // expected-error@+3{{OpenACC 'update' construct may not appear in place of the statement following a label statement}} + LABEL: + // expected-warning@+1{{OpenACC clause 'device' not yet implemented}} +#pragma acc update device(Var) + + // For loops are OK. + for (;;) + // expected-warning@+1{{OpenACC clause 'device' not yet implemented}} +#pragma acc update device(Var) + + // Checking for 'async', which requires an 'int' expression. +#pragma acc update async + +#pragma acc update async(getI()) + // expected-error@+2{{expected ')'}} + // expected-note@+1{{to match this '('}} +#pragma acc update async(getI(), getI()) + // expected-error@+2{{OpenACC 'async' clause cannot appear more than once on a 'update' directive}} + // expected-note@+1{{previous clause is here}} +#pragma acc update async(getI()) async(getI()) + // expected-error@+1{{OpenACC clause 'async' requires expression of integer type ('struct NotConvertible' invalid)}} +#pragma acc update async(NC) + + // Checking for 'wait', which has a complicated set arguments. +#pragma acc update wait +#pragma acc update wait() +#pragma acc update wait(getI(), getI()) +#pragma acc update wait(devnum: getI(): getI()) +#pragma acc update wait(devnum: getI(): queues: getI(), getI()) + // expected-error@+1{{OpenACC clause 'wait' requires expression of integer type ('struct NotConvertible' invalid)}} +#pragma acc update wait(devnum:NC : 5) + // expected-error@+1{{OpenACC clause 'wait' requires expression of integer type ('struct NotConvertible' invalid)}} +#pragma acc update 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 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 self(Array[0:1]) + + // expected-error@+1{{OpenACC sub-array is not allowed here}} +#pragma acc update self(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 self(Single.MemberOfComp) + +#pragma acc update self(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 self(Array[0:1]) + + // expected-error@+1{{OpenACC sub-array is not allowed here}} +#pragma acc update self(Array[0:1].MemberOfComp) +} + |