Hi!

As the testcase shows, if we have a clause with reference to dependent type,
during the processing_template_decl finish_omp_clauses we would reject it
rather than deferring checking of that until instantiation.

Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux,
committed to trunk, queued for backporting to release branches.

2019-06-21  Jakub Jelinek  <ja...@redhat.com>

        PR c++/90950
        * semantics.c (finish_omp_clauses): Don't reject references to
        incomplete types if processing_template_decl.

        * g++.dg/gomp/lastprivate-1.C: New test.

--- gcc/cp/semantics.c.jj       2019-06-17 23:18:53.621850057 +0200
+++ gcc/cp/semantics.c  2019-06-20 16:34:11.111784663 +0200
@@ -7831,7 +7831,8 @@ finish_omp_clauses (tree clauses, enum c
          t = require_complete_type (t);
          if (t == error_mark_node)
            remove = true;
-         else if (TYPE_REF_P (TREE_TYPE (t))
+         else if (!processing_template_decl
+                  && TYPE_REF_P (TREE_TYPE (t))
                   && !complete_type_or_else (TREE_TYPE (TREE_TYPE (t)), t))
            remove = true;
        }
--- gcc/testsuite/g++.dg/gomp/lastprivate-1.C.jj        2019-06-20 
16:33:28.980441681 +0200
+++ gcc/testsuite/g++.dg/gomp/lastprivate-1.C   2019-06-20 16:37:05.420066376 
+0200
@@ -0,0 +1,16 @@
+// PR c++/90950
+// { dg-do compile }
+
+template <typename T>
+T
+foo (void)
+{
+  T y = 0;
+  T &x = y;
+  #pragma omp parallel for lastprivate (x)
+  for (int i = 0; i < 8; ++i)
+    x = i;
+  return x;
+}
+
+int a = foo<int> ();

        Jakub

Reply via email to