public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r9-9394] openmp: Fix C ICE on OpenMP atomics
@ 2021-04-20 23:30 Jakub Jelinek
0 siblings, 0 replies; only message in thread
From: Jakub Jelinek @ 2021-04-20 23:30 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:28a164db98d7cb8fa82ac3699471830284502021
commit r9-9394-g28a164db98d7cb8fa82ac3699471830284502021
Author: Jakub Jelinek <jakub@redhat.com>
Date: Tue Nov 24 09:04:28 2020 +0100
openmp: Fix C ICE on OpenMP atomics
c_parser_binary_expression was using build2 to create a temporary holder
for binary expression that c_parser_atomic and c_finish_omp_atomic can then
handle. The latter performs then all the needed checking.
Unfortunately, build2 performs some checking too, e.g. PLUS_EXPR vs.
POINTER_PLUS_EXPR or matching types of the arguments, nothing we can guarantee
at the parsing time. So we need something like C++ build_min_nt*. This
patch implements that inline.
2020-11-24 Jakub Jelinek <jakub@redhat.com>
PR c/97958
* c-parser.c (c_parser_binary_expression): For omp atomic binary
expressions, use make_node instead of build2 to avoid checking build2
performs.
* c-c++-common/gomp/pr97958.c: New test.
(cherry picked from commit 1cd47144fd250f37206c8e2a0cc7d51c25ad368c)
Diff:
---
gcc/c/c-parser.c | 10 +++++++---
gcc/testsuite/c-c++-common/gomp/pr97958.c | 17 +++++++++++++++++
2 files changed, 24 insertions(+), 3 deletions(-)
diff --git a/gcc/c/c-parser.c b/gcc/c/c-parser.c
index 53e90c78a47..bfeacaa0a45 100644
--- a/gcc/c/c-parser.c
+++ b/gcc/c/c-parser.c
@@ -7034,9 +7034,13 @@ c_parser_binary_expression (c_parser *parser, struct c_expr *after,
&& stack[1].expr.value != error_mark_node \
&& (c_tree_equal (stack[0].expr.value, omp_atomic_lhs) \
|| c_tree_equal (stack[1].expr.value, omp_atomic_lhs))) \
- stack[0].expr.value \
- = build2 (stack[1].op, TREE_TYPE (stack[0].expr.value), \
- stack[0].expr.value, stack[1].expr.value); \
+ { \
+ tree t = make_node (stack[1].op); \
+ TREE_TYPE (t) = TREE_TYPE (stack[0].expr.value); \
+ TREE_OPERAND (t, 0) = stack[0].expr.value; \
+ TREE_OPERAND (t, 1) = stack[1].expr.value; \
+ stack[0].expr.value = t; \
+ } \
else \
stack[sp - 1].expr = parser_build_binary_op (stack[sp].loc, \
stack[sp].op, \
diff --git a/gcc/testsuite/c-c++-common/gomp/pr97958.c b/gcc/testsuite/c-c++-common/gomp/pr97958.c
new file mode 100644
index 00000000000..5a6de02f373
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/gomp/pr97958.c
@@ -0,0 +1,17 @@
+/* PR c/97958 */
+
+int *p;
+
+void
+foo (void)
+{
+ #pragma omp atomic
+ p = p + 1;
+}
+
+void
+bar (void)
+{
+ #pragma omp atomic /* { dg-error "invalid expression type for '#pragma omp atomic'" } */
+ bar = bar + 1;
+}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2021-04-20 23:30 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-20 23:30 [gcc r9-9394] openmp: Fix C ICE on OpenMP atomics Jakub Jelinek
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).