]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: re PR c++/81314 (Undefined reference to a function with -fopenmp)
authorJakub Jelinek <jakub@redhat.com>
Fri, 15 Sep 2017 21:42:20 +0000 (23:42 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Fri, 15 Sep 2017 21:42:20 +0000 (23:42 +0200)
Backported from mainline
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.

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

From-SVN: r252864

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

index 4140997c61a6751160ca46859f047682688d04a3..807ed46048237aa0d3fd940f5863a6b807846170 100644 (file)
@@ -1,3 +1,12 @@
+2017-09-15  Jakub Jelinek  <jakub@redhat.com>
+
+       Backported from mainline
+       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-08-14  Paolo Carlini  <paolo.carlini@oracle.com>
 
        PR c++/71570
index 23201d3cec5b148f5db950a5aa4dad19d2beac10..58037e56e6c44adb6e51d6adc82e85a31411182c 100644 (file)
@@ -853,6 +853,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))
@@ -905,6 +907,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 bba190c221e1d660602df25237f6e6c22a770388..a8db5f768343afa3ad013620a3338baa3558425a 100644 (file)
@@ -1,6 +1,11 @@
 2017-09-15  Jakub Jelinek  <jakub@redhat.com>
 
        Backported from mainline
+       2017-09-14  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/81314
+       * testsuite/libgomp.c++/pr81314.C: New test.
+
        2017-08-09  Jakub Jelinek  <jakub@redhat.com>
 
        PR c/81687
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);
+  }
+}