* [committed] Fix OpenMP atomic and for condition C++ parsing (PR c++/84341)
@ 2018-02-12 22:49 Jakub Jelinek
0 siblings, 0 replies; only message in thread
From: Jakub Jelinek @ 2018-02-12 22:49 UTC (permalink / raw)
To: gcc-patches
Hi!
In these cases, we want the tree to be just a placeholder for the operation
plus 2 operands, we are going to take it appart later; by using build_min
we can avoid the asserts build2_loc does, because the operands might not
have the same type etc.
Bootstrapped/regtested on x86_64-linux and i686-linux, committed to trunk.
2018-02-12 Jakub Jelinek <jakub@redhat.com>
PR c++/84341
* parser.c (cp_parser_binary_expression): Use build_min instead of
build2_loc to build the no_toplevel_fold_p toplevel binary expression.
* c-c++-common/gomp/pr84341.c: New test.
--- gcc/cp/parser.c.jj 2018-02-12 19:17:37.939216029 +0100
+++ gcc/cp/parser.c 2018-02-12 20:05:55.287322491 +0100
@@ -9330,12 +9330,14 @@ cp_parser_binary_expression (cp_parser*
if (no_toplevel_fold_p
&& lookahead_prec <= current.prec
&& sp == stack)
- current.lhs = build2_loc (combined_loc,
- current.tree_type,
- TREE_CODE_CLASS (current.tree_type)
- == tcc_comparison
- ? boolean_type_node : TREE_TYPE (current.lhs),
- current.lhs, rhs);
+ {
+ current.lhs
+ = build_min (current.tree_type,
+ TREE_CODE_CLASS (current.tree_type) == tcc_comparison
+ ? boolean_type_node : TREE_TYPE (current.lhs),
+ current.lhs.get_value (), rhs.get_value ());
+ SET_EXPR_LOCATION (current.lhs, combined_loc);
+ }
else
{
current.lhs = build_x_binary_op (combined_loc, current.tree_type,
--- gcc/testsuite/c-c++-common/gomp/pr84341.c.jj 2018-02-12 20:08:20.500327702 +0100
+++ gcc/testsuite/c-c++-common/gomp/pr84341.c 2018-02-12 20:08:00.290326972 +0100
@@ -0,0 +1,10 @@
+/* PR c++/84341 */
+/* { dg-do compile } */
+/* { dg-options "-fopenmp" } */
+
+void
+foo (int i)
+{
+ #pragma omp atomic
+ i = &i + 1; /* { dg-error "invalid form of" } */
+}
Jakub
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2018-02-12 22:49 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-12 22:49 [committed] Fix OpenMP atomic and for condition C++ parsing (PR c++/84341) 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).