diff options
author | Jakub Jelinek <jakub@redhat.com> | 2008-12-28 21:06:00 +0100 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2008-12-28 21:06:00 +0100 |
commit | e4ebaef35b3de79c05c616044c6e370b83e17a1f (patch) | |
tree | f612b0b6482de3bfab5e984231c0d017244573cb /gcc/cp | |
parent | 2008239a953d29cd5a2dd45a08f3c903999080e0 (diff) | |
download | gcc-e4ebaef35b3de79c05c616044c6e370b83e17a1f.zip gcc-e4ebaef35b3de79c05c616044c6e370b83e17a1f.tar.gz gcc-e4ebaef35b3de79c05c616044c6e370b83e17a1f.tar.bz2 |
re PR c++/38650 (Trouble with volatile and #pragma omp for)
PR c++/38650
* semantics.c (finish_omp_for): Don't add CLEANUP_POINT_EXPR
around volatile iteration var in condition and/or increment
expression.
* testsuite/libgomp.c/pr38650.c: New test.
* testsuite/libgomp.c++/pr38650.C: New test.
From-SVN: r142940
Diffstat (limited to 'gcc/cp')
-rw-r--r-- | gcc/cp/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/cp/semantics.c | 48 |
2 files changed, 42 insertions, 13 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 2771f7e..df04c1b 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,10 @@ +2008-12-28 Jakub Jelinek <jakub@redhat.com> + + PR c++/38650 + * semantics.c (finish_omp_for): Don't add CLEANUP_POINT_EXPR + around volatile iteration var in condition and/or increment + expression. + 2008-12-27 Jakub Jelinek <jakub@redhat.com> PR c++/38639 diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index d5efb83..62d2462 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -4262,13 +4262,25 @@ finish_omp_for (location_t locus, tree declv, tree initv, tree condv, } else init = build2 (MODIFY_EXPR, void_type_node, decl, init); - if (cond && TREE_SIDE_EFFECTS (cond) && COMPARISON_CLASS_P (cond)) + if (cond + && TREE_SIDE_EFFECTS (cond) + && COMPARISON_CLASS_P (cond) + && !processing_template_decl) { - int n = TREE_SIDE_EFFECTS (TREE_OPERAND (cond, 1)) != 0; - tree t = TREE_OPERAND (cond, n); + 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); - if (!processing_template_decl) - TREE_OPERAND (cond, n) + 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) @@ -4292,21 +4304,31 @@ finish_omp_for (location_t locus, tree declv, tree initv, tree condv, for (i = 0; i < TREE_VEC_LENGTH (OMP_FOR_INCR (omp_for)); i++) { - tree incr = TREE_VEC_ELT (OMP_FOR_INCR (omp_for), i); + decl = TREE_OPERAND (TREE_VEC_ELT (OMP_FOR_INIT (omp_for), i), 0); + incr = TREE_VEC_ELT (OMP_FOR_INCR (omp_for), i); if (TREE_CODE (incr) != MODIFY_EXPR) continue; if (TREE_SIDE_EFFECTS (TREE_OPERAND (incr, 1)) - && BINARY_CLASS_P (TREE_OPERAND (incr, 1))) + && BINARY_CLASS_P (TREE_OPERAND (incr, 1)) + && !processing_template_decl) { - tree t = TREE_OPERAND (incr, 1); - int n = TREE_SIDE_EFFECTS (TREE_OPERAND (t, 1)) != 0; + tree t = TREE_OPERAND (TREE_OPERAND (incr, 1), 0); + if (TREE_SIDE_EFFECTS (t) + && t != decl + && (TREE_CODE (t) != NOP_EXPR + || TREE_OPERAND (t, 0) != decl)) + TREE_OPERAND (TREE_OPERAND (incr, 1), 0) + = fold_build_cleanup_point_expr (TREE_TYPE (t), t); - if (!processing_template_decl) - TREE_OPERAND (t, n) - = fold_build_cleanup_point_expr (TREE_TYPE (TREE_OPERAND (t, n)), - TREE_OPERAND (t, n)); + t = TREE_OPERAND (TREE_OPERAND (incr, 1), 1); + if (TREE_SIDE_EFFECTS (t) + && t != decl + && (TREE_CODE (t) != NOP_EXPR + || TREE_OPERAND (t, 0) != decl)) + TREE_OPERAND (TREE_OPERAND (incr, 1), 1) + = fold_build_cleanup_point_expr (TREE_TYPE (t), t); } if (orig_incr) |