re PR c++/84341 (ICE with #pragma omp atomic)
authorJakub Jelinek <jakub@redhat.com>
Mon, 12 Feb 2018 22:25:41 +0000 (23:25 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Mon, 12 Feb 2018 22:25:41 +0000 (23:25 +0100)
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.

From-SVN: r257607

gcc/cp/ChangeLog
gcc/cp/parser.c
gcc/testsuite/ChangeLog
gcc/testsuite/c-c++-common/gomp/pr84341.c [new file with mode: 0644]

index 2f12a35a1b536483b5c431483002791c38bfcab0..c2b19d8eb593f92c5d4aecc56028f2c197ccfcb5 100644 (file)
@@ -1,3 +1,9 @@
+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.
+
 2018-02-12  Nathan Sidwell  <nathan@acm.org>
 
        PR c++/84263
index e1e8741d21de84ede76be197f3a99e7348a9e777..9a05e4fc812b4549c6a00e0ac0ad775a737634d7 100644 (file)
@@ -9330,12 +9330,14 @@ cp_parser_binary_expression (cp_parser* parser, bool cast_p,
       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,
index a384383960452a28bbeb220eecb51ad80735e222..40261753993ad4571585bc096d177f2192fb5283 100644 (file)
@@ -1,3 +1,8 @@
+2018-02-12  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/84341
+       * c-c++-common/gomp/pr84341.c: New test.
+
 2018-02-12  Thomas Koenig  <tkoenig@gcc.gnu.org>
 
        PR fortran/68746
diff --git a/gcc/testsuite/c-c++-common/gomp/pr84341.c b/gcc/testsuite/c-c++-common/gomp/pr84341.c
new file mode 100644 (file)
index 0000000..557f1ba
--- /dev/null
@@ -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" } */
+}