commit 355411e5415f65e09a06f42d400761fff065f7c7 Author: Julian Brown Date: Fri Aug 31 17:30:20 2018 -0700 Allow this[:] array slices for OpenACC 2018-09-03 Joseph Myers Julian Brown * semantics.c (handle_omp_array_sections_1): Allow array sections with "this" pointer for OpenACC. diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 676de01..98511ed 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -4598,7 +4598,8 @@ handle_omp_array_sections_1 (tree c, tree t, vec &types, omp_clause_code_name[OMP_CLAUSE_CODE (c)]); return error_mark_node; } - else if (TREE_CODE (t) == PARM_DECL + else if (ort == C_ORT_OMP + && TREE_CODE (t) == PARM_DECL && DECL_ARTIFICIAL (t) && DECL_NAME (t) == this_identifier) { diff --git a/libgomp/testsuite/libgomp.oacc-c++/this.C b/libgomp/testsuite/libgomp.oacc-c++/this.C new file mode 100644 index 0000000..510c690 --- /dev/null +++ b/libgomp/testsuite/libgomp.oacc-c++/this.C @@ -0,0 +1,43 @@ +#include +#include +using namespace std; + +class test { + public: + int a; + + test () + { + a = -1; +#pragma acc enter data copyin (this[0:1]) + } + + ~test () + { +#pragma acc exit data delete (this[0:1]) + } + + void set (int i) + { + a = i; +#pragma acc update device (this[0:1]) + } + + int get () + { +#pragma acc update host (this[0:1]) + return a; + } +}; + +int +main () +{ + test t; + + t.set (4); + if (t.get () != 4) + abort (); + + return 0; +}