From 87a5ccfb7cbabcf510f7909387a16cc0f73931f3 Mon Sep 17 00:00:00 2001 From: Joseph Myers Date: Mon, 29 Oct 2018 14:31:20 +0000 Subject: [PATCH] [OpenACC] Support C++ "this" in OpenACC directives 2018-10-29 Joseph Myers Julian Brown * semantics.c (handle_omp_array_sections_1): Allow array sections with "this" pointer for OpenACC. Co-Authored-By: Julian Brown From-SVN: r265591 --- gcc/cp/ChangeLog | 7 +++++ gcc/cp/semantics.c | 3 ++- libgomp/ChangeLog | 5 ++++ libgomp/testsuite/libgomp.oacc-c++/this.C | 43 +++++++++++++++++++++++++++++++ 4 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 libgomp/testsuite/libgomp.oacc-c++/this.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 27b739c..9130b86 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,10 @@ +2018-10-29 Joseph Myers + Julian Brown + + PR c++/66053 + * semantics.c (handle_omp_array_sections_1): Allow array + sections with "this" pointer for OpenACC. + 2018-10-25 Jason Merrill * parser.c (cp_parser_sizeof_operand): Remove redundant use of diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index c7f53d1..4c05365 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -4600,7 +4600,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/ChangeLog b/libgomp/ChangeLog index 9c2ae06..81fae2f 100644 --- a/libgomp/ChangeLog +++ b/libgomp/ChangeLog @@ -1,3 +1,8 @@ +2018-10-29 Joseph Myers + Julian Brown + + * testsuite/libgomp.oacc-c++/this.C: New. + 2018-09-18 Cesar Philippidis * plugin/plugin-nvptx.c (struct cuda_map): New. 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; +} -- 2.7.4