From db81e8c42e121e62a00587b12d2b972dfcfb98c0 Mon Sep 17 00:00:00 2001 From: erichkeane Date: Mon, 6 Jan 2025 11:59:04 -0800 Subject: [OpenACC] Initial sema implementation of 'update' construct This executable construct has a larger list of clauses than some of the others, plus has some additional restrictions. This patch implements the AST node, plus the 'cannot be the body of a if, while, do, switch, or label' statement restriction. Future patches will handle the rest of the restrictions, which are based on clauses. --- clang/test/SemaOpenACC/update-construct.cpp | 113 ++++++++++++++++++++++++++++ 1 file changed, 113 insertions(+) create mode 100644 clang/test/SemaOpenACC/update-construct.cpp (limited to 'clang/test/SemaOpenACC/update-construct.cpp') diff --git a/clang/test/SemaOpenACC/update-construct.cpp b/clang/test/SemaOpenACC/update-construct.cpp new file mode 100644 index 0000000..3bada82 --- /dev/null +++ b/clang/test/SemaOpenACC/update-construct.cpp @@ -0,0 +1,113 @@ +// RUN: %clang_cc1 %s -fopenacc -verify + +void uses() { + int Var; + // expected-warning@+2{{OpenACC clause 'async' not yet implemented}} + // expected-warning@+1{{OpenACC clause 'self' not yet implemented}} +#pragma acc update async self(Var) + // expected-warning@+2{{OpenACC clause 'wait' not yet implemented}} + // expected-warning@+1{{OpenACC clause 'self' not yet implemented}} +#pragma acc update wait self(Var) + // expected-warning@+2{{OpenACC clause 'self' not yet implemented}} + // expected-warning@+1{{OpenACC clause 'device_type' not yet implemented}} +#pragma acc update self(Var) device_type(I) + // expected-warning@+2{{OpenACC clause 'if' not yet implemented}} + // expected-warning@+1{{OpenACC clause 'self' not yet implemented}} +#pragma acc update if(true) self(Var) + // expected-warning@+2{{OpenACC clause 'if_present' not yet implemented}} + // expected-warning@+1{{OpenACC clause 'self' not yet implemented}} +#pragma acc update if_present self(Var) + // expected-warning@+1{{OpenACC clause 'self' not yet implemented}} +#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) + + // TODO: OpenACC: These all should diagnose as they aren't allowed after + // device_type. + // expected-warning@+3{{OpenACC clause 'self' not yet implemented}} + // expected-warning@+2{{OpenACC clause 'device_type' not yet implemented}} + // expected-warning@+1{{OpenACC clause 'device_type' not yet implemented}} +#pragma acc update self(Var) device_type(I) device_type(I) + // expected-warning@+3{{OpenACC clause 'self' not yet implemented}} + // expected-warning@+2{{OpenACC clause 'device_type' not yet implemented}} + // expected-warning@+1{{OpenACC clause 'if' not yet implemented}} +#pragma acc update self(Var) device_type(I) if(true) + // expected-warning@+3{{OpenACC clause 'self' not yet implemented}} + // expected-warning@+2{{OpenACC clause 'device_type' not yet implemented}} + // expected-warning@+1{{OpenACC clause 'if_present' not yet implemented}} +#pragma acc update self(Var) device_type(I) if_present + // expected-warning@+2{{OpenACC clause 'device_type' not yet implemented}} + // expected-warning@+1{{OpenACC clause 'self' not yet implemented}} +#pragma acc update device_type(I) self(Var) + // expected-warning@+2{{OpenACC clause 'device_type' not yet implemented}} + // expected-warning@+1{{OpenACC clause 'host' not yet implemented}} +#pragma acc update device_type(I) host(Var) + // expected-warning@+2{{OpenACC clause 'device_type' not yet implemented}} + // expected-warning@+1{{OpenACC clause 'device' not yet implemented}} +#pragma acc update device_type(I) device(Var) + // These 2 are OK. + // expected-warning@+3{{OpenACC clause 'self' not yet implemented}} + // expected-warning@+2{{OpenACC clause 'device_type' not yet implemented}} + // expected-warning@+1{{OpenACC clause 'async' not yet implemented}} +#pragma acc update self(Var) device_type(I) async + // expected-warning@+3{{OpenACC clause 'self' not yet implemented}} + // expected-warning@+2{{OpenACC clause 'device_type' not yet implemented}} + // expected-warning@+1{{OpenACC clause 'wait' not yet implemented}} +#pragma acc update self(Var) device_type(I) wait + + // TODO: OpenACC: These should diagnose because there isn't at least 1 of + // 'self', 'host', or 'device'. + // expected-warning@+1{{OpenACC clause 'async' not yet implemented}} +#pragma acc update async + // expected-warning@+1{{OpenACC clause 'wait' not yet implemented}} +#pragma acc update wait + // expected-warning@+1{{OpenACC clause 'device_type' not yet implemented}} +#pragma acc update device_type(I) + // expected-warning@+1{{OpenACC clause 'if' not yet implemented}} +#pragma acc update if(true) + // expected-warning@+1{{OpenACC clause 'if_present' not yet implemented}} +#pragma acc update if_present + + // TODO: OpenACC: There should only be a max of 1 'if'. + // expected-warning@+2{{OpenACC clause 'if' not yet implemented}} + // expected-warning@+1{{OpenACC clause 'if' not yet implemented}} +#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) +} -- cgit v1.1 From dd1e8aa09c0ab453a0566165b68e6a62fcd055e1 Mon Sep 17 00:00:00 2001 From: erichkeane Date: Tue, 7 Jan 2025 08:19:31 -0800 Subject: [OpenACC] Enable 'if' and 'if_present' for 'update' construct The only restriction on 'if' is that only 1 can appear on an update construct, so this enforces that. 'if_present' has no restrictions. --- clang/test/SemaOpenACC/update-construct.cpp | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) (limited to 'clang/test/SemaOpenACC/update-construct.cpp') diff --git a/clang/test/SemaOpenACC/update-construct.cpp b/clang/test/SemaOpenACC/update-construct.cpp index 3bada82..c9998cd 100644 --- a/clang/test/SemaOpenACC/update-construct.cpp +++ b/clang/test/SemaOpenACC/update-construct.cpp @@ -1,5 +1,6 @@ // RUN: %clang_cc1 %s -fopenacc -verify +struct NotConvertible{} NC; void uses() { int Var; // expected-warning@+2{{OpenACC clause 'async' not yet implemented}} @@ -11,10 +12,8 @@ void uses() { // expected-warning@+2{{OpenACC clause 'self' not yet implemented}} // expected-warning@+1{{OpenACC clause 'device_type' not yet implemented}} #pragma acc update self(Var) device_type(I) - // expected-warning@+2{{OpenACC clause 'if' not yet implemented}} // expected-warning@+1{{OpenACC clause 'self' not yet implemented}} #pragma acc update if(true) self(Var) - // expected-warning@+2{{OpenACC clause 'if_present' not yet implemented}} // expected-warning@+1{{OpenACC clause 'self' not yet implemented}} #pragma acc update if_present self(Var) // expected-warning@+1{{OpenACC clause 'self' not yet implemented}} @@ -30,13 +29,11 @@ void uses() { // expected-warning@+2{{OpenACC clause 'device_type' not yet implemented}} // expected-warning@+1{{OpenACC clause 'device_type' not yet implemented}} #pragma acc update self(Var) device_type(I) device_type(I) - // expected-warning@+3{{OpenACC clause 'self' not yet implemented}} - // expected-warning@+2{{OpenACC clause 'device_type' not yet implemented}} - // expected-warning@+1{{OpenACC clause 'if' not yet implemented}} + // expected-warning@+2{{OpenACC clause 'self' not yet implemented}} + // expected-warning@+1{{OpenACC clause 'device_type' not yet implemented}} #pragma acc update self(Var) device_type(I) if(true) - // expected-warning@+3{{OpenACC clause 'self' not yet implemented}} - // expected-warning@+2{{OpenACC clause 'device_type' not yet implemented}} - // expected-warning@+1{{OpenACC clause 'if_present' not yet implemented}} + // expected-warning@+2{{OpenACC clause 'self' not yet implemented}} + // expected-warning@+1{{OpenACC clause 'device_type' not yet implemented}} #pragma acc update self(Var) device_type(I) if_present // expected-warning@+2{{OpenACC clause 'device_type' not yet implemented}} // expected-warning@+1{{OpenACC clause 'self' not yet implemented}} @@ -65,14 +62,15 @@ void uses() { #pragma acc update wait // expected-warning@+1{{OpenACC clause 'device_type' not yet implemented}} #pragma acc update device_type(I) - // expected-warning@+1{{OpenACC clause 'if' not yet implemented}} #pragma acc update if(true) - // expected-warning@+1{{OpenACC clause 'if_present' not yet implemented}} #pragma acc update if_present - // TODO: OpenACC: There should only be a max of 1 'if'. - // expected-warning@+2{{OpenACC clause 'if' not yet implemented}} - // expected-warning@+1{{OpenACC clause 'if' not yet implemented}} + // expected-error@+2{{value of type 'struct NotConvertible' is not contextually convertible to 'bool'}} + // expected-warning@+1{{OpenACC clause 'device_type' not yet implemented}} +#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 -- cgit v1.1 From e2c1b1fed43619bdb88bb5e99b7e8c2fff9f6553 Mon Sep 17 00:00:00 2001 From: erichkeane Date: Tue, 7 Jan 2025 10:02:35 -0800 Subject: [OpenACC] enable 'async' and 'wait' for 'update' construct These work the same here as they do for every other construct, so this is as simple as enabling them and writing tests, which this patch does. --- clang/test/SemaOpenACC/update-construct.cpp | 45 ++++++++++++++++++++++------- 1 file changed, 35 insertions(+), 10 deletions(-) (limited to 'clang/test/SemaOpenACC/update-construct.cpp') diff --git a/clang/test/SemaOpenACC/update-construct.cpp b/clang/test/SemaOpenACC/update-construct.cpp index c9998cd..6aa7613 100644 --- a/clang/test/SemaOpenACC/update-construct.cpp +++ b/clang/test/SemaOpenACC/update-construct.cpp @@ -1,12 +1,11 @@ // RUN: %clang_cc1 %s -fopenacc -verify struct NotConvertible{} NC; +int getI(); void uses() { int Var; - // expected-warning@+2{{OpenACC clause 'async' not yet implemented}} // expected-warning@+1{{OpenACC clause 'self' not yet implemented}} #pragma acc update async self(Var) - // expected-warning@+2{{OpenACC clause 'wait' not yet implemented}} // expected-warning@+1{{OpenACC clause 'self' not yet implemented}} #pragma acc update wait self(Var) // expected-warning@+2{{OpenACC clause 'self' not yet implemented}} @@ -45,20 +44,16 @@ void uses() { // expected-warning@+1{{OpenACC clause 'device' not yet implemented}} #pragma acc update device_type(I) device(Var) // These 2 are OK. - // expected-warning@+3{{OpenACC clause 'self' not yet implemented}} - // expected-warning@+2{{OpenACC clause 'device_type' not yet implemented}} - // expected-warning@+1{{OpenACC clause 'async' not yet implemented}} + // expected-warning@+2{{OpenACC clause 'self' not yet implemented}} + // expected-warning@+1{{OpenACC clause 'device_type' not yet implemented}} #pragma acc update self(Var) device_type(I) async - // expected-warning@+3{{OpenACC clause 'self' not yet implemented}} - // expected-warning@+2{{OpenACC clause 'device_type' not yet implemented}} - // expected-warning@+1{{OpenACC clause 'wait' not yet implemented}} + // expected-warning@+2{{OpenACC clause 'self' not yet implemented}} + // expected-warning@+1{{OpenACC clause 'device_type' not yet implemented}} #pragma acc update self(Var) device_type(I) wait // TODO: OpenACC: These should diagnose because there isn't at least 1 of // 'self', 'host', or 'device'. - // expected-warning@+1{{OpenACC clause 'async' not yet implemented}} #pragma acc update async - // expected-warning@+1{{OpenACC clause 'wait' not yet implemented}} #pragma acc update wait // expected-warning@+1{{OpenACC clause 'device_type' not yet implemented}} #pragma acc update device_type(I) @@ -108,4 +103,34 @@ void uses() { 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) } -- cgit v1.1 From 666eee0ef85ff8a81904b9375fc22bc48cecc6b1 Mon Sep 17 00:00:00 2001 From: erichkeane Date: Tue, 7 Jan 2025 11:24:15 -0800 Subject: [OpenACC] enable 'device_type' for the 'update' construct This has a similar restriction to 'set' in that only 'async' and 'wait' are disallowed, so this implements that restriction and enables 'device_type'. --- clang/test/SemaOpenACC/update-construct.cpp | 44 +++++++++++++---------------- 1 file changed, 19 insertions(+), 25 deletions(-) (limited to 'clang/test/SemaOpenACC/update-construct.cpp') diff --git a/clang/test/SemaOpenACC/update-construct.cpp b/clang/test/SemaOpenACC/update-construct.cpp index 6aa7613..04c0aaa 100644 --- a/clang/test/SemaOpenACC/update-construct.cpp +++ b/clang/test/SemaOpenACC/update-construct.cpp @@ -8,8 +8,7 @@ void uses() { #pragma acc update async self(Var) // expected-warning@+1{{OpenACC clause 'self' not yet implemented}} #pragma acc update wait self(Var) - // expected-warning@+2{{OpenACC clause 'self' not yet implemented}} - // expected-warning@+1{{OpenACC clause 'device_type' not yet implemented}} + // expected-warning@+1{{OpenACC clause 'self' not yet implemented}} #pragma acc update self(Var) device_type(I) // expected-warning@+1{{OpenACC clause 'self' not yet implemented}} #pragma acc update if(true) self(Var) @@ -22,46 +21,41 @@ void uses() { // expected-warning@+1{{OpenACC clause 'device' not yet implemented}} #pragma acc update device(Var) - // TODO: OpenACC: These all should diagnose as they aren't allowed after - // device_type. - // expected-warning@+3{{OpenACC clause 'self' not yet implemented}} - // expected-warning@+2{{OpenACC clause 'device_type' not yet implemented}} - // expected-warning@+1{{OpenACC clause 'device_type' not yet implemented}} -#pragma acc update self(Var) device_type(I) device_type(I) - // expected-warning@+2{{OpenACC clause 'self' not yet implemented}} - // expected-warning@+1{{OpenACC clause 'device_type' not yet implemented}} + // expected-warning@+3{{OpenACC clause 'self' not yet implemented}} + // 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-warning@+2{{OpenACC clause 'self' not yet implemented}} - // expected-warning@+1{{OpenACC clause 'device_type' not yet implemented}} + // expected-warning@+3{{OpenACC clause 'self' not yet implemented}} + // 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-warning@+2{{OpenACC clause 'device_type' not yet implemented}} - // expected-warning@+1{{OpenACC clause 'self' not yet implemented}} + // 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-warning@+2{{OpenACC clause 'device_type' not yet implemented}} - // expected-warning@+1{{OpenACC clause 'host' not yet implemented}} + // 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-warning@+2{{OpenACC clause 'device_type' not yet implemented}} - // expected-warning@+1{{OpenACC clause 'device' not yet implemented}} + // 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. - // expected-warning@+2{{OpenACC clause 'self' not yet implemented}} - // expected-warning@+1{{OpenACC clause 'device_type' not yet implemented}} + // expected-warning@+1{{OpenACC clause 'self' not yet implemented}} #pragma acc update self(Var) device_type(I) async - // expected-warning@+2{{OpenACC clause 'self' not yet implemented}} - // expected-warning@+1{{OpenACC clause 'device_type' not yet implemented}} + // expected-warning@+1{{OpenACC clause 'self' not yet implemented}} #pragma acc update self(Var) device_type(I) wait + // Unless otherwise specified, we assume 'device_type' can happen after itself. + // expected-warning@+1{{OpenACC clause 'self' not yet implemented}} +#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 - // expected-warning@+1{{OpenACC clause 'device_type' not yet implemented}} #pragma acc update device_type(I) #pragma acc update if(true) #pragma acc update if_present - // expected-error@+2{{value of type 'struct NotConvertible' is not contextually convertible to 'bool'}} - // expected-warning@+1{{OpenACC clause 'device_type' not yet implemented}} + // 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}} -- cgit v1.1 From 2c2accbcc6b0f132182a35b65ac76c038912cd1e Mon Sep 17 00:00:00 2001 From: erichkeane Date: Wed, 8 Jan 2025 10:42:40 -0800 Subject: [OpenACC] Enable 'self' sema for 'update' construct The 'self' clause is an unfortunately difficult one, as it has a significantly different meaning between 'update' and the other constructs. This patch introduces a way for the 'self' clause to work as both. I considered making this two separate AST nodes (one for 'self' on 'update' and one for the others), however this makes the automated macros/etc for supporting a clause break. Instead, 'self' has the ability to act as either a condition or as a var-list clause. As this is the only one of its kind, it is implemented all within it. If in the future we have more that work like this, we should consider rewriting a lot of the macros that we use to make clauses work, and make them separate ast nodes. --- clang/test/SemaOpenACC/update-construct.cpp | 59 +++++++++++++++++++++++------ 1 file changed, 48 insertions(+), 11 deletions(-) (limited to 'clang/test/SemaOpenACC/update-construct.cpp') diff --git a/clang/test/SemaOpenACC/update-construct.cpp b/clang/test/SemaOpenACC/update-construct.cpp index 04c0aaa..2abd7a3 100644 --- a/clang/test/SemaOpenACC/update-construct.cpp +++ b/clang/test/SemaOpenACC/update-construct.cpp @@ -4,28 +4,20 @@ struct NotConvertible{} NC; int getI(); void uses() { int Var; - // expected-warning@+1{{OpenACC clause 'self' not yet implemented}} #pragma acc update async self(Var) - // expected-warning@+1{{OpenACC clause 'self' not yet implemented}} #pragma acc update wait self(Var) - // expected-warning@+1{{OpenACC clause 'self' not yet implemented}} #pragma acc update self(Var) device_type(I) - // expected-warning@+1{{OpenACC clause 'self' not yet implemented}} #pragma acc update if(true) self(Var) - // expected-warning@+1{{OpenACC clause 'self' not yet implemented}} #pragma acc update if_present self(Var) - // expected-warning@+1{{OpenACC clause 'self' not yet implemented}} #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-warning@+3{{OpenACC clause 'self' not yet implemented}} // 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-warning@+3{{OpenACC clause 'self' not yet implemented}} // 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 @@ -39,12 +31,9 @@ void uses() { // expected-note@+1{{previous clause is here}} #pragma acc update device_type(I) device(Var) // These 2 are OK. - // expected-warning@+1{{OpenACC clause 'self' not yet implemented}} #pragma acc update self(Var) device_type(I) async - // expected-warning@+1{{OpenACC clause 'self' not yet implemented}} #pragma acc update self(Var) device_type(I) wait // Unless otherwise specified, we assume 'device_type' can happen after itself. - // expected-warning@+1{{OpenACC clause 'self' not yet implemented}} #pragma acc update self(Var) device_type(I) device_type(I) // TODO: OpenACC: These should diagnose because there isn't at least 1 of @@ -128,3 +117,51 @@ void uses() { // 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 +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();// 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) +} + -- cgit v1.1