diff mbox series

[committed] Fix OpenMP ICE with firstprivate in lambda in a template (PR c++/88988)

Message ID 20190130233043.GX2135@tucnak
State New
Headers show
Series [committed] Fix OpenMP ICE with firstprivate in lambda in a template (PR c++/88988) | expand

Commit Message

Jakub Jelinek Jan. 30, 2019, 11:30 p.m. UTC
Hi!

DECL_OMP_PRIVATIZED_MEMBER VAR_DECLs aren't capture proxies, handling them
that way results in various ICEs.

Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux,
committed to trunk.

2019-01-30  Jakub Jelinek  <jakub@redhat.com>

	PR c++/88988
	* lambda.c (is_capture_proxy): Don't return true for
	DECL_OMP_PRIVATIZED_MEMBER artificial vars.

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


	Jakub
diff mbox series

Patch

--- gcc/cp/lambda.c.jj	2019-01-30 08:35:47.055054187 +0100
+++ gcc/cp/lambda.c	2019-01-30 14:22:45.324085959 +0100
@@ -263,6 +263,9 @@  is_capture_proxy (tree decl)
 	  && !DECL_ANON_UNION_VAR_P (decl)
 	  && !DECL_DECOMPOSITION_P (decl)
 	  && !DECL_FNAME_P (decl)
+	  && !(DECL_ARTIFICIAL (decl)
+	       && DECL_LANG_SPECIFIC (decl)
+	       && DECL_OMP_PRIVATIZED_MEMBER (decl))
 	  && LAMBDA_FUNCTION_P (DECL_CONTEXT (decl)));
 }
 
--- libgomp/testsuite/libgomp.c++/pr88988.C.jj	2019-01-30 14:33:42.134276321 +0100
+++ libgomp/testsuite/libgomp.c++/pr88988.C	2019-01-30 14:33:16.911696846 +0100
@@ -0,0 +1,28 @@ 
+// PR c++/88988
+// { dg-do compile }
+// { dg-additional-options "-std=c++14" }
+
+extern "C" void abort ();
+
+template <typename T>
+struct A {
+  A () : a(), b()
+  {
+    [&] ()
+    {
+#pragma omp task firstprivate (a) shared (b)
+      b = ++a;
+#pragma omp taskwait
+    } ();
+  }
+
+  T a, b;
+};
+
+int
+main ()
+{
+  A<int> x;
+  if (x.a != 0 || x.b != 1)
+    abort ();
+}