diff options
Diffstat (limited to 'gcc/cp')
-rw-r--r-- | gcc/cp/pt.c | 27 | ||||
-rw-r--r-- | gcc/cp/semantics.c | 74 |
2 files changed, 68 insertions, 33 deletions
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index efc69d5..07b9956 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -17449,7 +17449,16 @@ tsubst_omp_for_iterator (tree t, int i, tree declv, tree &orig_declv, else decl = RECUR (decl); } - init = RECUR (init); + if (init && TREE_CODE (init) == TREE_VEC) + { + init = copy_node (init); + TREE_VEC_ELT (init, 0) + = tsubst_decl (TREE_VEC_ELT (init, 0), args, complain); + TREE_VEC_ELT (init, 1) = RECUR (TREE_VEC_ELT (init, 1)); + TREE_VEC_ELT (init, 2) = RECUR (TREE_VEC_ELT (init, 2)); + } + else + init = RECUR (init); if (orig_declv && OMP_FOR_ORIG_DECLS (t)) { @@ -17501,7 +17510,21 @@ tsubst_omp_for_iterator (tree t, int i, tree declv, tree &orig_declv, if (!range_for) { - cond = RECUR (TREE_VEC_ELT (OMP_FOR_COND (t), i)); + cond = TREE_VEC_ELT (OMP_FOR_COND (t), i); + if (COMPARISON_CLASS_P (cond) + && TREE_CODE (TREE_OPERAND (cond, 1)) == TREE_VEC) + { + tree lhs = RECUR (TREE_OPERAND (cond, 0)); + tree rhs = copy_node (TREE_OPERAND (cond, 1)); + TREE_VEC_ELT (rhs, 0) + = tsubst_decl (TREE_VEC_ELT (rhs, 0), args, complain); + TREE_VEC_ELT (rhs, 1) = RECUR (TREE_VEC_ELT (rhs, 1)); + TREE_VEC_ELT (rhs, 2) = RECUR (TREE_VEC_ELT (rhs, 2)); + cond = build2 (TREE_CODE (cond), TREE_TYPE (cond), + lhs, rhs); + } + else + cond = RECUR (cond); incr = TREE_VEC_ELT (OMP_FOR_INCR (t), i); if (TREE_CODE (incr) == MODIFY_EXPR) { diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 2e65c27..d63cea9 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -8594,7 +8594,7 @@ handle_omp_for_class_iterator (int i, location_t locus, enum tree_code code, TREE_OPERAND (cond, 1), iter); return true; } - if (!c_omp_check_loop_iv_exprs (locus, orig_declv, + if (!c_omp_check_loop_iv_exprs (locus, orig_declv, i, TREE_VEC_ELT (declv, i), NULL_TREE, cond, cp_walk_subtrees)) return true; @@ -8980,8 +8980,8 @@ finish_omp_for (location_t locus, enum tree_code code, tree declv, tree orig_init; FOR_EACH_VEC_ELT (*orig_inits, i, orig_init) if (orig_init - && !c_omp_check_loop_iv_exprs (locus, orig_declv - ? orig_declv : declv, + && !c_omp_check_loop_iv_exprs (locus, + orig_declv ? orig_declv : declv, i, TREE_VEC_ELT (declv, i), orig_init, NULL_TREE, cp_walk_subtrees)) fail = true; @@ -9075,35 +9075,11 @@ finish_omp_for (location_t locus, enum tree_code code, tree declv, return NULL; } - if (!processing_template_decl) - { - init = fold_build_cleanup_point_expr (TREE_TYPE (init), init); - init = cp_build_modify_expr (elocus, decl, NOP_EXPR, init, - tf_warning_or_error); - } + if (!processing_template_decl && TREE_CODE (init) != TREE_VEC) + init = cp_build_modify_expr (elocus, decl, NOP_EXPR, init, + tf_warning_or_error); else init = build2 (MODIFY_EXPR, void_type_node, decl, init); - if (cond - && TREE_SIDE_EFFECTS (cond) - && COMPARISON_CLASS_P (cond) - && !processing_template_decl) - { - tree t = TREE_OPERAND (cond, 0); - if (TREE_SIDE_EFFECTS (t) - && t != decl - && (TREE_CODE (t) != NOP_EXPR - || TREE_OPERAND (t, 0) != decl)) - TREE_OPERAND (cond, 0) - = fold_build_cleanup_point_expr (TREE_TYPE (t), t); - - t = TREE_OPERAND (cond, 1); - if (TREE_SIDE_EFFECTS (t) - && t != decl - && (TREE_CODE (t) != NOP_EXPR - || TREE_OPERAND (t, 0) != decl)) - TREE_OPERAND (cond, 1) - = fold_build_cleanup_point_expr (TREE_TYPE (t), t); - } if (decl == error_mark_node || init == error_mark_node) return NULL; @@ -9132,9 +9108,45 @@ finish_omp_for (location_t locus, enum tree_code code, tree declv, for (i = 0; i < TREE_VEC_LENGTH (OMP_FOR_INCR (omp_for)); i++) { - decl = TREE_OPERAND (TREE_VEC_ELT (OMP_FOR_INIT (omp_for), i), 0); + init = TREE_VEC_ELT (OMP_FOR_INIT (omp_for), i); + decl = TREE_OPERAND (init, 0); + cond = TREE_VEC_ELT (OMP_FOR_COND (omp_for), i); incr = TREE_VEC_ELT (OMP_FOR_INCR (omp_for), i); + if (!processing_template_decl) + { + if (TREE_CODE (TREE_OPERAND (init, 1)) == TREE_VEC) + { + tree t = TREE_VEC_ELT (TREE_OPERAND (init, 1), 1); + TREE_VEC_ELT (TREE_OPERAND (init, 1), 1) + = fold_build_cleanup_point_expr (TREE_TYPE (t), t); + t = TREE_VEC_ELT (TREE_OPERAND (init, 1), 2); + TREE_VEC_ELT (TREE_OPERAND (init, 1), 2) + = fold_build_cleanup_point_expr (TREE_TYPE (t), t); + } + else + { + tree t = TREE_OPERAND (init, 1); + TREE_OPERAND (init, 1) + = fold_build_cleanup_point_expr (TREE_TYPE (t), t); + } + if (TREE_CODE (TREE_OPERAND (cond, 1)) == TREE_VEC) + { + tree t = TREE_VEC_ELT (TREE_OPERAND (cond, 1), 1); + TREE_VEC_ELT (TREE_OPERAND (cond, 1), 1) + = fold_build_cleanup_point_expr (TREE_TYPE (t), t); + t = TREE_VEC_ELT (TREE_OPERAND (cond, 1), 2); + TREE_VEC_ELT (TREE_OPERAND (cond, 1), 2) + = fold_build_cleanup_point_expr (TREE_TYPE (t), t); + } + else + { + tree t = TREE_OPERAND (cond, 1); + TREE_OPERAND (cond, 1) + = fold_build_cleanup_point_expr (TREE_TYPE (t), t); + } + } + if (TREE_CODE (incr) != MODIFY_EXPR) continue; |