re PR c++/67511 (ICE with invalid OpenMP random access iterator)
authorJakub Jelinek <jakub@redhat.com>
Thu, 10 Sep 2015 07:30:29 +0000 (09:30 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Thu, 10 Sep 2015 07:30:29 +0000 (09:30 +0200)
PR c++/67511
* semantics.c (handle_omp_for_class_iterator): Don't wrap
error_mark_node into a NOP_EXPR to void_type_node.

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

From-SVN: r227606

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

index 1cc576a3f22943a123804e7d18c3c61ddf34b189..4b32f5ae3832a4aa303dff4791aa990c1282d3f2 100644 (file)
@@ -1,3 +1,9 @@
+2015-09-10  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/67511
+       * semantics.c (handle_omp_for_class_iterator): Don't wrap
+       error_mark_node into a NOP_EXPR to void_type_node.
+
 2015-09-09  Paolo Carlini  <paolo.carlini@oracle.com>
 
        PR c++/53184
index 2a69ab0863fa882d87bc27dfce38946d8b59e7c3..5c3f1bea808646bb79ec19192b2851f40126a0f0 100644 (file)
@@ -6453,7 +6453,8 @@ handle_omp_for_class_iterator (int i, location_t locus, tree declv, tree initv,
   iter_init = build_x_modify_expr (elocus,
                                   iter, PLUS_EXPR, iter_init,
                                   tf_warning_or_error);
-  iter_init = build1 (NOP_EXPR, void_type_node, iter_init);
+  if (iter_init != error_mark_node)
+    iter_init = build1 (NOP_EXPR, void_type_node, iter_init);
   finish_expr_stmt (iter_init);
   finish_expr_stmt (build_x_modify_expr (elocus,
                                         last, NOP_EXPR, decl,
index 140766d3ef736a112bc8d4b97d6c3991f2279836..fba8b15559584a08a524ec9a49c7153fd57bd9d2 100644 (file)
@@ -1,5 +1,8 @@
 2015-09-10  Jakub Jelinek  <jakub@redhat.com>
 
+       PR c++/67511
+       * g++.dg/gomp/pr67511.C: New test.
+
        PR c/67502
        * c-c++-common/gomp/pr67502.c: New test.
 
diff --git a/gcc/testsuite/g++.dg/gomp/pr67511.C b/gcc/testsuite/g++.dg/gomp/pr67511.C
new file mode 100644 (file)
index 0000000..3e0e9a3
--- /dev/null
@@ -0,0 +1,20 @@
+// PR c++/67511
+// { dg-do compile }
+// { dg-options "-fopenmp" }
+
+struct I
+{
+  I ();
+  I (const I &);
+  I &operator++ ();
+  bool operator< (const I &) const;
+};
+__PTRDIFF_TYPE__ operator- (const I &, const I &);
+
+void
+foo (I &x, I &y)
+{
+#pragma omp for
+  for (I i = x; i < y; ++i)    // { dg-error "no match for" }
+    ;
+}