]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[OpenACC] Support C++ "this" in OpenACC directives
authorJoseph Myers <joseph@codesourcery.com>
Mon, 29 Oct 2018 14:31:20 +0000 (14:31 +0000)
committerJulian Brown <jules@gcc.gnu.org>
Mon, 29 Oct 2018 14:31:20 +0000 (14:31 +0000)
2018-10-29  Joseph Myers  <joseph@codesourcery.com>
    Julian Brown  <julian@codesourcery.com>

* semantics.c (handle_omp_array_sections_1): Allow array sections with
"this" pointer for OpenACC.

Co-Authored-By: Julian Brown <julian@codesourcery.com>
From-SVN: r265591

gcc/cp/ChangeLog
gcc/cp/semantics.c
libgomp/ChangeLog
libgomp/testsuite/libgomp.oacc-c++/this.C [new file with mode: 0644]

index 27b739c7a15d22be416b931f4739932f529be55a..9130b8663d3fef771834110e0f35c87d36653216 100644 (file)
@@ -1,3 +1,10 @@
+2018-10-29  Joseph Myers  <joseph@codesourcery.com>
+           Julian Brown  <julian@codesourcery.com>
+
+        PR c++/66053
+        * semantics.c (handle_omp_array_sections_1): Allow array
+        sections with "this" pointer for OpenACC.
+
 2018-10-25  Jason Merrill  <jason@redhat.com>
 
        * parser.c (cp_parser_sizeof_operand): Remove redundant use of
index c7f53d1206e853acaa60d4fa1e78d02661956f94..4c053655e00945e94e7d43462595e9cf7c86dec5 100644 (file)
@@ -4600,7 +4600,8 @@ handle_omp_array_sections_1 (tree c, tree t, vec<tree> &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)
        {
index 9c2ae06b4e1544e551bb24f8a913701da722f531..81fae2fb9802725d547e4c434e94e52f6b0c93d7 100644 (file)
@@ -1,3 +1,8 @@
+2018-10-29  Joseph Myers  <joseph@codesourcery.com>
+           Julian Brown  <julian@codesourcery.com>
+
+       * testsuite/libgomp.oacc-c++/this.C: New.
+
 2018-09-18  Cesar Philippidis  <cesar@codesourcery.com>
 
        * 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 (file)
index 0000000..510c690
--- /dev/null
@@ -0,0 +1,43 @@
+#include <cstdlib>
+#include <iostream>
+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;
+}