]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: re PR c++/84448 (ICE with broken condition in parallel for loop)
authorJakub Jelinek <jakub@redhat.com>
Mon, 25 Jun 2018 17:23:21 +0000 (19:23 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Mon, 25 Jun 2018 17:23:21 +0000 (19:23 +0200)
Backported from mainline
2018-02-19  Jakub Jelinek  <jakub@redhat.com>

PR c++/84448
* parser.c (cp_parser_binary_expression): For no_toplevel_fold_p, if
either operand is error_mark_node, set current.lhs to that instead of
creating a binary op with error_mark_node operands.

* g++.dg/gomp/pr84448.C: New test.

From-SVN: r262065

gcc/cp/ChangeLog
gcc/cp/parser.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/gomp/pr84448.C [new file with mode: 0644]

index a48560fa5d3f63925a29969b35f731190ff37b68..ebf38497bb821dde798de6e699f28fa4360c436f 100644 (file)
@@ -1,6 +1,13 @@
 2018-06-25  Jakub Jelinek  <jakub@redhat.com>
 
        Backported from mainline
+       2018-02-19  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/84448
+       * parser.c (cp_parser_binary_expression): For no_toplevel_fold_p, if
+       either operand is error_mark_node, set current.lhs to that instead of
+       creating a binary op with error_mark_node operands.
+
        2018-02-12  Jakub Jelinek  <jakub@redhat.com>
 
        PR c++/84341
index b3a4ce4fe4679803ddef4f31157fa5130fe29171..4a49a2c6d747d7b9995120e934731c77403f57d2 100644 (file)
@@ -8921,12 +8921,18 @@ cp_parser_binary_expression (cp_parser* parser, bool cast_p,
          && lookahead_prec <= current.prec
          && sp == stack)
        {
-         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);
+         if (current.lhs == error_mark_node || rhs == error_mark_node)
+           current.lhs = error_mark_node;
+         else
+           {
+             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
         {
index 1063fa095dffafbbf7ef6e50bd7c1ac59aa8a3fe..f0184b55576ea9748b6026a994fa7b5c18170f37 100644 (file)
@@ -1,6 +1,11 @@
 2018-06-25  Jakub Jelinek  <jakub@redhat.com>
 
        Backported from mainline
+       2018-02-19  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/84448
+       * g++.dg/gomp/pr84448.C: New test.
+
        2018-02-16  Jakub Jelinek  <jakub@redhat.com>
 
        PR ipa/84425
diff --git a/gcc/testsuite/g++.dg/gomp/pr84448.C b/gcc/testsuite/g++.dg/gomp/pr84448.C
new file mode 100644 (file)
index 0000000..3fad474
--- /dev/null
@@ -0,0 +1,17 @@
+// PR c++/84448
+// { dg-do compile }
+
+struct A
+{
+  operator int () const;
+  A& operator += (int);
+  A& operator ++ ();
+};
+
+void
+foo (A a, A b)
+{
+  #pragma omp for
+  for (A i = a; i <=; ++i)     // { dg-error "expected primary-expression before" }
+    ;                          // { dg-error "invalid controlling predicate" "" { target *-*-* } .-1 }
+}