re PR c++/81314 (Undefined reference to a function with -fopenmp)
authorJakub Jelinek <jakub@redhat.com>
Thu, 14 Sep 2017 20:18:17 +0000 (22:18 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Thu, 14 Sep 2017 20:18:17 +0000 (22:18 +0200)
PR c++/81314
* cp-gimplify.c (omp_var_to_track): Look through references.
(omp_cxx_notice_variable): Likewise.

* testsuite/libgomp.c++/pr81314.C: New test.

From-SVN: r252770

gcc/cp/ChangeLog
gcc/cp/cp-gimplify.c
libgomp/ChangeLog
libgomp/testsuite/libgomp.c++/pr81314.C [new file with mode: 0644]

index c0b7ba2ff69a0ffc25ca34ced3452386dcf2e143..1bda58141ce77432fa0dda6ae9bd515f15890582 100644 (file)
@@ -1,3 +1,9 @@
+2017-09-14  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/81314
+       * cp-gimplify.c (omp_var_to_track): Look through references.
+       (omp_cxx_notice_variable): Likewise.
+
 2017-09-13  Nathan Sidwell  <nathan@acm.org>
 
        Conv-op identifers not in identifier hash table
index 4a52aa50e77b8193f77c0d6eb3dc46051f9ca1a0..262485a5c1ff74a84774997a7ad88aa83c9883b5 100644 (file)
@@ -895,6 +895,8 @@ omp_var_to_track (tree decl)
   tree type = TREE_TYPE (decl);
   if (is_invisiref_parm (decl))
     type = TREE_TYPE (type);
+  else if (TREE_CODE (type) == REFERENCE_TYPE)
+    type = TREE_TYPE (type);
   while (TREE_CODE (type) == ARRAY_TYPE)
     type = TREE_TYPE (type);
   if (type == error_mark_node || !CLASS_TYPE_P (type))
@@ -947,6 +949,8 @@ omp_cxx_notice_variable (struct cp_genericize_omp_taskreg *omp_ctx, tree decl)
              tree type = TREE_TYPE (decl);
              if (is_invisiref_parm (decl))
                type = TREE_TYPE (type);
+             else if (TREE_CODE (type) == REFERENCE_TYPE)
+               type = TREE_TYPE (type);
              while (TREE_CODE (type) == ARRAY_TYPE)
                type = TREE_TYPE (type);
              get_copy_ctor (type, tf_none);
index 8e50b8083dce06bc8762e5e9866d06f4738ccb66..459dcffa5701321e873b6bbf5a2c9fbe2b21aa97 100644 (file)
@@ -1,3 +1,8 @@
+2017-09-14  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/81314
+       * testsuite/libgomp.c++/pr81314.C: New test.
+
 2017-09-03  Gerald Pfeifer  <gerald@pfeifer.com>
 
        * libgomp.texi (Top): www.openacc.org now uses https.
diff --git a/libgomp/testsuite/libgomp.c++/pr81314.C b/libgomp/testsuite/libgomp.c++/pr81314.C
new file mode 100644 (file)
index 0000000..afe8943
--- /dev/null
@@ -0,0 +1,38 @@
+// PR c++/81314
+// { dg-do link }
+
+template <int N>
+struct S {
+  S () { s = 0; }
+  S (const S &x) { s = x.s; }
+  ~S () {}
+  int s;
+};
+
+void
+foo (S<2> &x)
+{
+  #pragma omp taskloop
+  for (int i = 0; i < 100; ++i)
+    x.s++;
+}
+
+void
+bar (S<3> &x)
+{
+  #pragma omp task
+  x.s++;
+}
+
+int
+main ()
+{
+  S<2> s;
+  S<3> t;
+  #pragma omp parallel
+  #pragma omp master
+  {
+    foo (s);
+    bar (t);
+  }
+}