diff options
Diffstat (limited to 'gcc/cp/pt.c')
-rw-r--r-- | gcc/cp/pt.c | 59 |
1 files changed, 33 insertions, 26 deletions
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index b2916f8..82bf7dc 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -17437,6 +17437,13 @@ tsubst_omp_clauses (tree clauses, enum c_omp_region_type ort, = tsubst_omp_clause_decl (OMP_CLAUSE_DECL (oc), args, complain, in_decl, iterator_cache); break; + case OMP_CLAUSE_NUM_TEAMS: + if (OMP_CLAUSE_NUM_TEAMS_LOWER_EXPR (oc)) + OMP_CLAUSE_NUM_TEAMS_LOWER_EXPR (nc) + = tsubst_expr (OMP_CLAUSE_NUM_TEAMS_LOWER_EXPR (oc), args, + complain, in_decl, + /*integral_constant_expression_p=*/false); + /* FALLTHRU */ case OMP_CLAUSE_TILE: case OMP_CLAUSE_IF: case OMP_CLAUSE_NUM_THREADS: @@ -17445,7 +17452,6 @@ tsubst_omp_clauses (tree clauses, enum c_omp_region_type ort, case OMP_CLAUSE_FINAL: case OMP_CLAUSE_DEVICE: case OMP_CLAUSE_DIST_SCHEDULE: - case OMP_CLAUSE_NUM_TEAMS: case OMP_CLAUSE_THREAD_LIMIT: case OMP_CLAUSE_SAFELEN: case OMP_CLAUSE_SIMDLEN: @@ -18948,31 +18954,32 @@ tsubst_expr (tree t, tree args, tsubst_flags_t complain, tree in_decl, { tree teams = cp_walk_tree (&stmt, tsubst_find_omp_teams, NULL, NULL); if (teams) - { - /* For combined target teams, ensure the num_teams and - thread_limit clause expressions are evaluated on the host, - before entering the target construct. */ - tree c; - for (c = OMP_TEAMS_CLAUSES (teams); - c; c = OMP_CLAUSE_CHAIN (c)) - if ((OMP_CLAUSE_CODE (c) == OMP_CLAUSE_NUM_TEAMS - || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_THREAD_LIMIT) - && TREE_CODE (OMP_CLAUSE_OPERAND (c, 0)) != INTEGER_CST) - { - tree expr = OMP_CLAUSE_OPERAND (c, 0); - expr = force_target_expr (TREE_TYPE (expr), expr, tf_none); - if (expr == error_mark_node) - continue; - tmp = TARGET_EXPR_SLOT (expr); - add_stmt (expr); - OMP_CLAUSE_OPERAND (c, 0) = expr; - tree tc = build_omp_clause (OMP_CLAUSE_LOCATION (c), - OMP_CLAUSE_FIRSTPRIVATE); - OMP_CLAUSE_DECL (tc) = tmp; - OMP_CLAUSE_CHAIN (tc) = OMP_TARGET_CLAUSES (t); - OMP_TARGET_CLAUSES (t) = tc; - } - } + /* For combined target teams, ensure the num_teams and + thread_limit clause expressions are evaluated on the host, + before entering the target construct. */ + for (tree c = OMP_TEAMS_CLAUSES (teams); + c; c = OMP_CLAUSE_CHAIN (c)) + if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_NUM_TEAMS + || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_THREAD_LIMIT) + for (int i = 0; + i <= (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_NUM_TEAMS); ++i) + if (OMP_CLAUSE_OPERAND (c, i) + && TREE_CODE (OMP_CLAUSE_OPERAND (c, i)) != INTEGER_CST) + { + tree expr = OMP_CLAUSE_OPERAND (c, i); + expr = force_target_expr (TREE_TYPE (expr), expr, + tf_none); + if (expr == error_mark_node) + continue; + tmp = TARGET_EXPR_SLOT (expr); + add_stmt (expr); + OMP_CLAUSE_OPERAND (c, i) = expr; + tree tc = build_omp_clause (OMP_CLAUSE_LOCATION (c), + OMP_CLAUSE_FIRSTPRIVATE); + OMP_CLAUSE_DECL (tc) = tmp; + OMP_CLAUSE_CHAIN (tc) = OMP_TARGET_CLAUSES (t); + OMP_TARGET_CLAUSES (t) = tc; + } } add_stmt (t); break; |