OSDN Git Service

PR middle-end/27415
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 17 May 2006 08:35:01 +0000 (08:35 +0000)
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 17 May 2006 08:35:01 +0000 (08:35 +0000)
* tree.h (OMP_PARALLEL_COMBINED): Define.
* gimplify.c (struct gimplify_omp_ctx): Add is_combined_parallel field.
(new_omp_context): Add is_combined_parallel argument.
(gimplify_scan_omp_clauses): Add in_combined_parallel argument, adjust
new_omp_context caller.
(gimplify_omp_parallel, gimplify_omp_for, gimplify_omp_workshare):
Adjust gimplify_scan_omp_clauses callers.
(omp_is_private): Issue errors if iteration variable is firstprivate
or reduction in the current context.
* c-parser.c (c_parser_omp_parallel): Set OMP_PARALLEL_COMBINED
on combined parallel workshare constructs.
cp/
* parser.c (cp_parser_omp_parallel): Set OMP_PARALLEL_COMBINED
on combined parallel workshare constructs.
* pt.c (tsubst_expr): Copy OMP_PARALLEL_COMBINED flag.
fortran/
* trans-openmp.c (gfc_trans_omp_parallel_do,
gfc_trans_omp_parallel_sections, gfc_trans_omp_parallel_workshare): Set
OMP_PARALLEL_COMBINED flag.
testsuite/
* gcc.dg/gomp/pr27415.c: New test.
* g++.dg/gomp/pr27415.C: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@113846 138bc75d-0d04-0410-961f-82ee72b054a4

12 files changed:
gcc/ChangeLog
gcc/c-parser.c
gcc/cp/ChangeLog
gcc/cp/parser.c
gcc/cp/pt.c
gcc/fortran/ChangeLog
gcc/fortran/trans-openmp.c
gcc/gimplify.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/gomp/pr27415.C [new file with mode: 0644]
gcc/testsuite/gcc.dg/gomp/pr27415.c [new file with mode: 0644]
gcc/tree.h

index cc8816c..862e2bf 100644 (file)
@@ -1,3 +1,18 @@
+2006-05-17  Jakub Jelinek  <jakub@redhat.com>
+
+       PR middle-end/27415
+       * tree.h (OMP_PARALLEL_COMBINED): Define.
+       * gimplify.c (struct gimplify_omp_ctx): Add is_combined_parallel field.
+       (new_omp_context): Add is_combined_parallel argument.
+       (gimplify_scan_omp_clauses): Add in_combined_parallel argument, adjust
+       new_omp_context caller.
+       (gimplify_omp_parallel, gimplify_omp_for, gimplify_omp_workshare):
+       Adjust gimplify_scan_omp_clauses callers.
+       (omp_is_private): Issue errors if iteration variable is firstprivate
+       or reduction in the current context.
+       * c-parser.c (c_parser_omp_parallel): Set OMP_PARALLEL_COMBINED
+       on combined parallel workshare constructs.
+
 2006-05-16  H.J. Lu  <hongjiu.lu@intel.com>
 
        * Makefile.in (GCC_OBJS): Replace options.o with gcc-options.o.
index aad1c6b..8f6cafd 100644 (file)
@@ -7651,6 +7651,7 @@ c_parser_omp_parallel (c_parser *parser)
       if (stmt)
        OMP_FOR_CLAUSES (stmt) = ws_clause;
       stmt = c_finish_omp_parallel (par_clause, block);
+      OMP_PARALLEL_COMBINED (stmt) = 1;
       break;
 
     case PRAGMA_OMP_PARALLEL_SECTIONS:
@@ -7660,6 +7661,7 @@ c_parser_omp_parallel (c_parser *parser)
       if (stmt)
        OMP_SECTIONS_CLAUSES (stmt) = ws_clause;
       stmt = c_finish_omp_parallel (par_clause, block);
+      OMP_PARALLEL_COMBINED (stmt) = 1;
       break;
 
     default:
index 698ae1a..8a31857 100644 (file)
@@ -1,3 +1,10 @@
+2006-05-17  Jakub Jelinek  <jakub@redhat.com>
+
+       PR middle-end/27415
+       * parser.c (cp_parser_omp_parallel): Set OMP_PARALLEL_COMBINED
+       on combined parallel workshare constructs.
+       * pt.c (tsubst_expr): Copy OMP_PARALLEL_COMBINED flag.
+
 2006-05-16  H.J. Lu  <hongjiu.lu@intel.com>
 
        PR driver/26885
index c89c357..28c5007 100644 (file)
@@ -18842,7 +18842,10 @@ cp_parser_omp_parallel (cp_parser *parser, cp_token *pragma_tok)
     }
 
   cp_parser_end_omp_structured_block (parser, save);
-  return finish_omp_parallel (par_clause, block);
+  stmt = finish_omp_parallel (par_clause, block);
+  if (p_kind != PRAGMA_OMP_PARALLEL)
+    OMP_PARALLEL_COMBINED (stmt) = 1;
+  return stmt;
 }
 
 /* OpenMP 2.5:
index 7bbc2cc..ea3ff41 100644 (file)
@@ -8456,7 +8456,8 @@ tsubst_expr (tree t, tree args, tsubst_flags_t complain, tree in_decl)
                                args, complain, in_decl);
       stmt = begin_omp_parallel ();
       tsubst_expr (OMP_PARALLEL_BODY (t), args, complain, in_decl);
-      finish_omp_parallel (tmp, stmt);
+      OMP_PARALLEL_COMBINED (finish_omp_parallel (tmp, stmt))
+       = OMP_PARALLEL_COMBINED (t);
       break;
 
     case OMP_FOR:
index f07af3b..2e4f8fb 100644 (file)
@@ -1,3 +1,10 @@
+2006-05-17  Jakub Jelinek  <jakub@redhat.com>
+
+       PR middle-end/27415
+       * trans-openmp.c (gfc_trans_omp_parallel_do,
+       gfc_trans_omp_parallel_sections, gfc_trans_omp_parallel_workshare): Set
+       OMP_PARALLEL_COMBINED flag.
+
 2006-05-16  H.J. Lu  <hongjiu.lu@intel.com>
 
        PR driver/26885
index f33f1bd..b7c6f9e 100644 (file)
@@ -1095,6 +1095,7 @@ gfc_trans_omp_parallel_do (gfc_code *code)
   else
     poplevel (0, 0, 0);
   stmt = build4_v (OMP_PARALLEL, stmt, omp_clauses, NULL, NULL);
+  OMP_PARALLEL_COMBINED (stmt) = 1;
   gfc_add_expr_to_block (&block, stmt);
   return gfc_finish_block (&block);
 }
@@ -1119,6 +1120,7 @@ gfc_trans_omp_parallel_sections (gfc_code *code)
   else
     poplevel (0, 0, 0);
   stmt = build4_v (OMP_PARALLEL, stmt, omp_clauses, NULL, NULL);
+  OMP_PARALLEL_COMBINED (stmt) = 1;
   gfc_add_expr_to_block (&block, stmt);
   return gfc_finish_block (&block);
 }
@@ -1143,6 +1145,7 @@ gfc_trans_omp_parallel_workshare (gfc_code *code)
   else
     poplevel (0, 0, 0);
   stmt = build4_v (OMP_PARALLEL, stmt, omp_clauses, NULL, NULL);
+  OMP_PARALLEL_COMBINED (stmt) = 1;
   gfc_add_expr_to_block (&block, stmt);
   return gfc_finish_block (&block);
 }
index 279bd2b..a438974 100644 (file)
@@ -73,6 +73,7 @@ struct gimplify_omp_ctx
   location_t location;
   enum omp_clause_default_kind default_kind;
   bool is_parallel;
+  bool is_combined_parallel;
 };
 
 struct gimplify_ctx
@@ -259,7 +260,7 @@ splay_tree_compare_decl_uid (splay_tree_key xa, splay_tree_key xb)
 /* Create a new omp construct that deals with variable remapping.  */
 
 static struct gimplify_omp_ctx *
-new_omp_context (bool is_parallel)
+new_omp_context (bool is_parallel, bool is_combined_parallel)
 {
   struct gimplify_omp_ctx *c;
 
@@ -269,6 +270,7 @@ new_omp_context (bool is_parallel)
   c->privatized_types = pointer_set_create ();
   c->location = input_location;
   c->is_parallel = is_parallel;
+  c->is_combined_parallel = is_combined_parallel;
   c->default_kind = OMP_CLAUSE_DEFAULT_SHARED;
 
   return c;
@@ -4452,6 +4454,18 @@ omp_is_private (struct gimplify_omp_ctx *ctx, tree decl)
          else
            return false;
        }
+      else if ((n->value & GOVD_EXPLICIT) != 0
+              && (ctx == gimplify_omp_ctxp
+                  || (ctx->is_combined_parallel
+                      && gimplify_omp_ctxp->outer_context == ctx)))
+       {
+         if ((n->value & GOVD_FIRSTPRIVATE) != 0)
+           error ("iteration variable %qs should not be firstprivate",
+                  IDENTIFIER_POINTER (DECL_NAME (decl)));
+         else if ((n->value & GOVD_REDUCTION) != 0)
+           error ("iteration variable %qs should not be reduction",
+                  IDENTIFIER_POINTER (DECL_NAME (decl)));
+       }
       return true;
     }
 
@@ -4467,12 +4481,13 @@ omp_is_private (struct gimplify_omp_ctx *ctx, tree decl)
    and previous omp contexts.  */
 
 static void
-gimplify_scan_omp_clauses (tree *list_p, tree *pre_p, bool in_parallel)
+gimplify_scan_omp_clauses (tree *list_p, tree *pre_p, bool in_parallel,
+                          bool in_combined_parallel)
 {
   struct gimplify_omp_ctx *ctx, *outer_ctx;
   tree c;
 
-  ctx = new_omp_context (in_parallel);
+  ctx = new_omp_context (in_parallel, in_combined_parallel);
   outer_ctx = ctx->outer_context;
 
   while ((c = *list_p) != NULL)
@@ -4717,7 +4732,8 @@ gimplify_omp_parallel (tree *expr_p, tree *pre_p)
 {
   tree expr = *expr_p;
 
-  gimplify_scan_omp_clauses (&OMP_PARALLEL_CLAUSES (expr), pre_p, true);
+  gimplify_scan_omp_clauses (&OMP_PARALLEL_CLAUSES (expr), pre_p, true,
+                            OMP_PARALLEL_COMBINED (expr));
 
   push_gimplify_context ();
 
@@ -4743,7 +4759,7 @@ gimplify_omp_for (tree *expr_p, tree *pre_p)
 
   for_stmt = *expr_p;
 
-  gimplify_scan_omp_clauses (&OMP_FOR_CLAUSES (for_stmt), pre_p, false);
+  gimplify_scan_omp_clauses (&OMP_FOR_CLAUSES (for_stmt), pre_p, false, false);
 
   t = OMP_FOR_INIT (for_stmt);
   gcc_assert (TREE_CODE (t) == MODIFY_EXPR);
@@ -4825,7 +4841,7 @@ gimplify_omp_workshare (tree *expr_p, tree *pre_p)
 {
   tree stmt = *expr_p;
 
-  gimplify_scan_omp_clauses (&OMP_CLAUSES (stmt), pre_p, false);
+  gimplify_scan_omp_clauses (&OMP_CLAUSES (stmt), pre_p, false, false);
   gimplify_to_stmt_list (&OMP_BODY (stmt));
   gimplify_adjust_omp_clauses (&OMP_CLAUSES (stmt));
 
index efcbdfa..b5339b2 100644 (file)
@@ -1,5 +1,11 @@
 2006-05-17  Jakub Jelinek  <jakub@redhat.com>
 
+       PR middle-end/27415
+       * gcc.dg/gomp/pr27415.c: New test.
+       * g++.dg/gomp/pr27415.C: New test.
+
+2006-05-17  Jakub Jelinek  <jakub@redhat.com>
+
        PR tree-optimization/27549
        * g++.dg/tree-ssa/pr27549.C: New test.
 
diff --git a/gcc/testsuite/g++.dg/gomp/pr27415.C b/gcc/testsuite/g++.dg/gomp/pr27415.C
new file mode 100644 (file)
index 0000000..81f0ed5
--- /dev/null
@@ -0,0 +1,50 @@
+// PR middle-end/27415
+// { dg-do compile }
+
+void
+test1 (void)
+{
+  int i = 0;
+#pragma omp parallel
+#pragma omp for firstprivate (i)               // { dg-error "should not be firstprivate" }
+  for (i = 0; i < 10; i++)
+    ;
+}
+
+void
+test2 (void)
+{
+  int i = 0;
+#pragma omp parallel for firstprivate (i)
+  for (i = 0; i < 10; i++)                     // { dg-error "should not be firstprivate" }
+    ;
+}
+
+void
+test3 (void)
+{
+  int i = 0;
+#pragma omp parallel
+#pragma omp for reduction (+:i)                        // { dg-error "should not be reduction" }
+  for (i = 0; i < 10; i++)
+    ;
+}
+
+void
+test4 (void)
+{
+  int i = 0;
+#pragma omp parallel for reduction (*:i)
+  for (i = 0; i < 10; i++)                     // { dg-error "should not be reduction" }
+    ;
+}
+
+void
+test5 (void)
+{
+  int i = 0;
+#pragma omp parallel firstprivate (i)
+#pragma omp for
+  for (i = 0; i < 10; i++)
+    ;
+}
diff --git a/gcc/testsuite/gcc.dg/gomp/pr27415.c b/gcc/testsuite/gcc.dg/gomp/pr27415.c
new file mode 100644 (file)
index 0000000..418eaf6
--- /dev/null
@@ -0,0 +1,50 @@
+/* PR middle-end/27415 */
+/* { dg-do compile } */
+
+void
+test1 (void)
+{
+  int i = 0;
+#pragma omp parallel
+#pragma omp for firstprivate (i)               /* { dg-error "should not be firstprivate" } */
+  for (i = 0; i < 10; i++)
+    ;
+}
+
+void
+test2 (void)
+{
+  int i = 0;
+#pragma omp parallel for firstprivate (i)
+  for (i = 0; i < 10; i++)                     /* { dg-error "should not be firstprivate" } */
+    ;
+}
+
+void
+test3 (void)
+{
+  int i = 0;
+#pragma omp parallel
+#pragma omp for reduction (+:i)                        /* { dg-error "should not be reduction" } */
+  for (i = 0; i < 10; i++)
+    ;
+}
+
+void
+test4 (void)
+{
+  int i = 0;
+#pragma omp parallel for reduction (*:i)
+  for (i = 0; i < 10; i++)                     /* { dg-error "should not be reduction" } */
+    ;
+}
+
+void
+test5 (void)
+{
+  int i = 0;
+#pragma omp parallel firstprivate (i)
+#pragma omp for
+  for (i = 0; i < 10; i++)
+    ;
+}
index 7a4ee33..55a5d8f 100644 (file)
@@ -443,6 +443,8 @@ struct tree_common GTY(())
           OMP_RETURN
        OMP_SECTION_LAST in
           OMP_SECTION
+       OMP_PARALLEL_COMBINED in
+          OMP_PARALLEL
 
    protected_flag:
 
@@ -1583,6 +1585,11 @@ struct tree_constructor GTY(())
 #define OMP_RETURN_NOWAIT(NODE) \
   TREE_PRIVATE (OMP_RETURN_CHECK (NODE))
 
+/* True on an OMP_PARALLEL statement if it represents an explicit
+   combined parallel work-sharing constructs.  */
+#define OMP_PARALLEL_COMBINED(NODE) \
+  TREE_PRIVATE (OMP_PARALLEL_CHECK (NODE))
+
 /* True on a PRIVATE clause if its decl is kept around for debugging
    information only and its DECL_VALUE_EXPR is supposed to point
    to what it has been remapped to.  */