aboutsummaryrefslogtreecommitdiff
path: root/gcc/c-parser.c
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2010-08-30 19:16:29 +0200
committerJakub Jelinek <jakub@gcc.gnu.org>2010-08-30 19:16:29 +0200
commitf2b11865fe81940d2061a924c3428a7915897fe9 (patch)
tree266d290f0a93cf7641282147388454e9d5f59918 /gcc/c-parser.c
parentbd9c7fb90927f0f22e6bbbb5f809bb8e5f6eaa95 (diff)
downloadgcc-f2b11865fe81940d2061a924c3428a7915897fe9.zip
gcc-f2b11865fe81940d2061a924c3428a7915897fe9.tar.gz
gcc-f2b11865fe81940d2061a924c3428a7915897fe9.tar.bz2
re PR middle-end/45423 (#pragma omp atomic on bool has issues)
PR middle-end/45423 * gimplify.c (goa_stabilize_expr): Handle TRUTH_NOT_EXPR and TRUTH_{AND,OR,XOR}_EXPR. * c-parser.c (c_parser_omp_atomic): Handle boolean {PRE,POST}_{INC,DEC}REMENT. cp/ * parser.c (cp_parser_omp_atomic): Handle boolean {PRE,POST}_INCREMENT. testsuite/ * gcc.dg/gomp/atomic-12.c: New test. * gcc.dg/gomp/atomic-13.c: New test. * gcc.dg/gomp/atomic-14.c: New test. * g++.dg/gomp/atomic-11.C: New test. * g++.dg/gomp/atomic-12.C: New test. * g++.dg/gomp/atomic-13.C: New test. * g++.dg/gomp/atomic-14.C: New test. From-SVN: r163653
Diffstat (limited to 'gcc/c-parser.c')
-rw-r--r--gcc/c-parser.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/gcc/c-parser.c b/gcc/c-parser.c
index 031c688..13e6350 100644
--- a/gcc/c-parser.c
+++ b/gcc/c-parser.c
@@ -8004,6 +8004,42 @@ c_parser_omp_atomic (location_t loc, c_parser *parser)
rhs = integer_one_node;
break;
+ case COMPOUND_EXPR:
+ if (TREE_CODE (TREE_OPERAND (lhs, 0)) == SAVE_EXPR
+ && TREE_CODE (TREE_OPERAND (lhs, 1)) == COMPOUND_EXPR
+ && TREE_CODE (TREE_OPERAND (TREE_OPERAND (lhs, 1), 0)) == MODIFY_EXPR
+ && TREE_OPERAND (TREE_OPERAND (lhs, 1), 1) == TREE_OPERAND (lhs, 0)
+ && TREE_CODE (TREE_TYPE (TREE_OPERAND (TREE_OPERAND
+ (TREE_OPERAND (lhs, 1), 0), 0)))
+ == BOOLEAN_TYPE)
+ /* Undo effects of boolean_increment for post {in,de}crement. */
+ lhs = TREE_OPERAND (TREE_OPERAND (lhs, 1), 0);
+ /* FALLTHRU */
+ case MODIFY_EXPR:
+ if (TREE_CODE (lhs) == MODIFY_EXPR
+ && TREE_CODE (TREE_TYPE (TREE_OPERAND (lhs, 0))) == BOOLEAN_TYPE)
+ {
+ /* Undo effects of boolean_increment. */
+ if (integer_onep (TREE_OPERAND (lhs, 1)))
+ {
+ /* This is pre or post increment. */
+ rhs = TREE_OPERAND (lhs, 1);
+ lhs = TREE_OPERAND (lhs, 0);
+ code = NOP_EXPR;
+ break;
+ }
+ if (TREE_CODE (TREE_OPERAND (lhs, 1)) == TRUTH_NOT_EXPR
+ && TREE_OPERAND (lhs, 0)
+ == TREE_OPERAND (TREE_OPERAND (lhs, 1), 0))
+ {
+ /* This is pre or post decrement. */
+ rhs = TREE_OPERAND (lhs, 1);
+ lhs = TREE_OPERAND (lhs, 0);
+ code = NOP_EXPR;
+ break;
+ }
+ }
+ /* FALLTHRU */
default:
switch (c_parser_peek_token (parser)->type)
{