summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>2006-05-17 08:35:01 +0000
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>2006-05-17 08:35:01 +0000
commit87f7c31ef783d27c635cec533ca1d67789096966 (patch)
tree7de49861b990eff224e646e29a3ad1dd59004468
parent93c1299472e04fceb734d53cb35bc76e1586bc66 (diff)
downloadgcc-87f7c31ef783d27c635cec533ca1d67789096966.tar.gz
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. 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
-rw-r--r--gcc/ChangeLog15
-rw-r--r--gcc/c-parser.c2
-rw-r--r--gcc/cp/ChangeLog7
-rw-r--r--gcc/cp/parser.c5
-rw-r--r--gcc/cp/pt.c3
-rw-r--r--gcc/fortran/ChangeLog7
-rw-r--r--gcc/fortran/trans-openmp.c3
-rw-r--r--gcc/gimplify.c28
-rw-r--r--gcc/testsuite/ChangeLog6
-rw-r--r--gcc/testsuite/g++.dg/gomp/pr27415.C50
-rw-r--r--gcc/testsuite/gcc.dg/gomp/pr27415.c50
-rw-r--r--gcc/tree.h7
12 files changed, 175 insertions, 8 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index cc8816cb2af..862e2bf7274 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -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.
diff --git a/gcc/c-parser.c b/gcc/c-parser.c
index aad1c6bb048..8f6cafda284 100644
--- a/gcc/c-parser.c
+++ b/gcc/c-parser.c
@@ -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:
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 698ae1a58dc..8a318578fb3 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -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
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index c89c357e200..28c5007dafc 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -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:
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 7bbc2cc972f..ea3ff411b8d 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -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:
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index f07af3b0a5f..2e4f8fb3eb1 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -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
diff --git a/gcc/fortran/trans-openmp.c b/gcc/fortran/trans-openmp.c
index f33f1bd3741..b7c6f9e3bfb 100644
--- a/gcc/fortran/trans-openmp.c
+++ b/gcc/fortran/trans-openmp.c
@@ -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);
}
diff --git a/gcc/gimplify.c b/gcc/gimplify.c
index 279bd2b3ac2..a4389741e23 100644
--- a/gcc/gimplify.c
+++ b/gcc/gimplify.c
@@ -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));
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index efcbdfa9469..b5339b2ec1b 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -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
index 00000000000..81f0ed5c6b7
--- /dev/null
+++ b/gcc/testsuite/g++.dg/gomp/pr27415.C
@@ -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
index 00000000000..418eaf678e9
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/gomp/pr27415.c
@@ -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/tree.h b/gcc/tree.h
index 7a4ee33346a..55a5d8f8618 100644
--- a/gcc/tree.h
+++ b/gcc/tree.h
@@ -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. */