]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: re PR c++/84341 (ICE with #pragma omp atomic)
authorJakub Jelinek <jakub@redhat.com>
Mon, 25 Jun 2018 17:21:04 +0000 (19:21 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Mon, 25 Jun 2018 17:21:04 +0000 (19:21 +0200)
Backported from mainline
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.

From-SVN: r262062

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

index 9eb96f774db092cdbbca95e8adf2d4c4dd753524..a48560fa5d3f63925a29969b35f731190ff37b68 100644 (file)
@@ -1,6 +1,12 @@
 2018-06-25  Jakub Jelinek  <jakub@redhat.com>
 
        Backported from mainline
+       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-10  Jakub Jelinek  <jakub@redhat.com>
 
        PR sanitizer/83987
index 4157c53b668ab859b756d0864e9013a059272ee5..b3a4ce4fe4679803ddef4f31157fa5130fe29171 100644 (file)
@@ -8920,12 +8920,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 8530d2010f889853b4eea7610857c4babb616ef1..4e92dc30240d6c827ec60e3c560836d24f4aa3f1 100644 (file)
@@ -1,6 +1,11 @@
 2018-06-25  Jakub Jelinek  <jakub@redhat.com>
 
        Backported from mainline
+       2018-02-12  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/84341
+       * c-c++-common/gomp/pr84341.c: New test.
+
        2018-02-10  Jakub Jelinek  <jakub@redhat.com>
 
        PR sanitizer/83987
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" } */
+}