re PR c++/84448 (ICE with broken condition in parallel for loop)
authorJakub Jelinek <jakub@redhat.com>
Mon, 19 Feb 2018 19:16:26 +0000 (20:16 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Mon, 19 Feb 2018 19:16:26 +0000 (20:16 +0100)
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: r257821

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

index 58fc0935903ae433b23e34e9c5079e3ea177786d..870dde6388d2d57b242b41c28ffc575dc3f22955 100644 (file)
@@ -1,5 +1,10 @@
 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.
+
        PR c++/84430
        * constexpr.c (potential_constant_expression_1): Handle OMP_SIMD.
 
index 81c6f0128e63b690fc231fed8a1902afb7dac972..d8d788052ab130f6ebfeafca7dac47642c75a739 100644 (file)
@@ -9331,12 +9331,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 fcb1d33b8dafc8284a9a164469974a76155d759a..b4df63d996331c36d7b5d5ef1d56c59342a7cbc2 100644 (file)
@@ -1,5 +1,8 @@
 2018-02-19  Jakub Jelinek  <jakub@redhat.com>
 
+       PR c++/84448
+       * g++.dg/gomp/pr84448.C: New test.
+
        PR c++/84430
        * g++.dg/gomp/pr84430.C: New test.
 
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 }
+}