c: Fix up __builtin_assoc_barrier handling in the C FE [PR104427]
authorJakub Jelinek <jakub@redhat.com>
Wed, 9 Feb 2022 19:45:31 +0000 (20:45 +0100)
committerJakub Jelinek <jakub@redhat.com>
Wed, 9 Feb 2022 19:46:10 +0000 (20:46 +0100)
commit499f8d4c2bc585b985882b4716f35b4c1553ce32
tree0ccfe39e85279e622704fc53b6b2d72b86cd1554
parent2f9ab267e725ddf2b6b44113e4fc4fb8b2a6adfb
c: Fix up __builtin_assoc_barrier handling in the C FE [PR104427]

The following testcase ICEs, because when creating PAREN_EXPR for
__builtin_assoc_barrier the FE doesn't do the usual tweaks for
EXCESS_PRECISION_EXPR or C_MAYBE_CONST_EXPR.  I believe that the
declared effect of the builtin is just association barrier, so
e.g. excess precision should be still handled like if it wasn't
there.

The following patch uses build_unary_op to handle those.

2022-02-09  Jakub Jelinek  <jakub@redhat.com>

PR c/104427
* c-parser.cc (c_parser_postfix_expression)
<case RID_BUILTIN_ASSOC_BARRIER>: Use parser_build_unary_op
instead of build1_loc to build PAREN_EXPR.
* c-typeck.cc (build_unary_op): Handle PAREN_EXPR.
* c-fold.cc (c_fully_fold_internal): Likewise.

* gcc.dg/pr104427.c: New test.
gcc/c/c-fold.cc
gcc/c/c-parser.cc
gcc/c/c-typeck.cc
gcc/testsuite/gcc.dg/pr104427.c [new file with mode: 0644]