aboutsummaryrefslogtreecommitdiff
path: root/gcc/gimplify.c
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2006-05-17 10:35:01 +0200
committerJakub Jelinek <jakub@gcc.gnu.org>2006-05-17 10:35:01 +0200
commit761041be912de3a0344a507dbb718a49a9c19434 (patch)
tree7de49861b990eff224e646e29a3ad1dd59004468 /gcc/gimplify.c
parent3c5cbea7a14ac6b674443a6d3e0865a696af18ce (diff)
downloadgcc-761041be912de3a0344a507dbb718a49a9c19434.zip
gcc-761041be912de3a0344a507dbb718a49a9c19434.tar.gz
gcc-761041be912de3a0344a507dbb718a49a9c19434.tar.bz2
re PR middle-end/27415 (Iteration var in firstprivate or reduction clauses not reported)
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. From-SVN: r113846
Diffstat (limited to 'gcc/gimplify.c')
-rw-r--r--gcc/gimplify.c28
1 files changed, 22 insertions, 6 deletions
diff --git a/gcc/gimplify.c b/gcc/gimplify.c
index 279bd2b..a438974 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));