This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[gomp] fix sharing-2.f90


The nested private wouldn't get remapped properly, leading to an ICE.


r~


        * omp-low.c (scan_omp_nested) <OMP_CLAUSE_PRIVATE>: Replace
        OMP_CLAUSE_DECL with the new private decl.  Use a tree list
        for fixing up the variable sized decls.

Index: omp-low.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/omp-low.c,v
retrieving revision 1.1.2.33
diff -u -p -d -r1.1.2.33 omp-low.c
--- omp-low.c	21 Oct 2005 21:41:09 -0000	1.1.2.33
+++ omp-low.c	21 Oct 2005 23:55:28 -0000
@@ -780,7 +780,7 @@ static void
 scan_omp_nested (tree *stmt_p, omp_context *outer_ctx)
 {
   omp_context *ctx;
-  bool saw_var_sized = false;
+  tree var_sized_list = NULL;
   tree c, decl, stmt = *stmt_p;
 
   ctx = new_omp_context (stmt, outer_ctx);
@@ -793,8 +793,8 @@ scan_omp_nested (tree *stmt_p, omp_conte
 	case OMP_CLAUSE_PRIVATE:
 	  decl = OMP_CLAUSE_DECL (c);
 	  if (is_variable_sized (decl))
-	    saw_var_sized = true;
-	  install_var_private (decl, ctx);
+	    var_sized_list = tree_cons (NULL, decl, var_sized_list);
+	  OMP_CLAUSE_DECL (c) = install_var_private (decl, ctx);
 	  break;
 
 	case OMP_CLAUSE_FIRSTPRIVATE:
@@ -822,16 +822,8 @@ scan_omp_nested (tree *stmt_p, omp_conte
   /* Instantiate the VALUE_EXPR for variable sized variables.  We have
      to do this as a separate pass, since we need the pointer and size
      decls installed first.  */
-  if (saw_var_sized)
-    for (c = OMP_CLAUSES (stmt); c ; c = OMP_CLAUSE_CHAIN (c))
-      {
-	if (TREE_CODE (c) != OMP_CLAUSE_PRIVATE)
-	  continue;
-
-	decl = OMP_CLAUSE_DECL (c);
-	if (is_variable_sized (decl))
-	  fixup_variable_sized (decl, ctx);
-      }
+  for (c = var_sized_list; c ; c = TREE_CHAIN (c))
+    fixup_variable_sized (TREE_VALUE (c), ctx);
 
   scan_omp (&OMP_BODY (stmt), ctx);
 
Index: testsuite/gcc.dg/gomp/sharing-2.c
===================================================================
RCS file: testsuite/gcc.dg/gomp/sharing-2.c
diff -N testsuite/gcc.dg/gomp/sharing-2.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ testsuite/gcc.dg/gomp/sharing-2.c	21 Oct 2005 23:55:28 -0000
@@ -0,0 +1,25 @@
+/* { dg-do compile } */
+
+void
+foo (void)
+{
+  int i;
+  int a[10];
+  #pragma omp parallel private (i) shared (a)
+  {
+    i = 1;
+    #pragma omp parallel shared (a, i)
+    {
+      #pragma omp master
+	i = 2;
+      #pragma omp parallel private (i) shared (a)
+      {
+	for (i = 0; i < 10; i++)
+	  a[i] = i + 1;
+      }
+      #pragma omp master
+	i = 3;
+    }
+    i = 4;
+  }
+}


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]