[PATCH] Fix OpenMP ICE on incomplete type in shared clause (PR middle-end/35818)

Jakub Jelinek jakub@redhat.com
Thu Apr 3 18:57:00 GMT 2008


Hi!

is_variable_size assumes the argument has complete type, which is ensured in
all clauses but OMP_CLAUSE_SHARED.

2008-04-03  Jakub Jelinek  <jakub@redhat.com>

	PR middle-end/35818
	* omp-low.c (scan_sharing_clauses) <case OMP_CLAUSE_SHARED>: Don't
	call is_variable_sized if decl has incomplete type.

	* gcc.dg/gomp/pr35818.c: New test.

--- gcc/omp-low.c.jj	2008-04-03 18:17:20.000000000 +0200
+++ gcc/omp-low.c	2008-04-03 18:38:42.000000000 +0200
@@ -993,7 +993,8 @@ scan_sharing_clauses (tree clauses, omp_
 	case OMP_CLAUSE_SHARED:
 	  gcc_assert (is_parallel_ctx (ctx));
 	  decl = OMP_CLAUSE_DECL (c);
-	  gcc_assert (!is_variable_sized (decl));
+	  gcc_assert (!COMPLETE_TYPE_P (TREE_TYPE (decl))
+		      || !is_variable_sized (decl));
 	  by_ref = use_pointer_for_field (decl, ctx);
 	  /* Global variables don't need to be copied,
 	     the receiver side will use them directly.  */
--- gcc/testsuite/gcc.dg/gomp/pr35818.c.jj	2008-04-03 19:02:42.000000000 +0200
+++ gcc/testsuite/gcc.dg/gomp/pr35818.c	2008-04-03 19:01:56.000000000 +0200
@@ -0,0 +1,16 @@
+/* PR middle-end/35818 */
+/* { dg-do compile } */
+/* { dg-options "-fopenmp" } */
+
+extern int a[];
+
+void
+foo (void)
+{
+#pragma omp parallel
+#pragma omp master
+  a[3] = 1;
+#pragma omp parallel shared(a)
+#pragma omp master
+  a[3] = 1;
+}

	Jakub



More information about the Gcc-patches mailing list