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 2f12a35..c2b19d8 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 e1e8741..9a05e4f 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 a384383..4026175 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" } */
+}