From 4e4d2c41b9921ee5b8aa8e9d5874da8786e45559 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Thu, 10 Sep 2015 09:30:29 +0200 Subject: [PATCH] re PR c++/67511 (ICE with invalid OpenMP random access iterator) 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 | 6 ++++++ gcc/cp/semantics.c | 3 ++- gcc/testsuite/ChangeLog | 3 +++ gcc/testsuite/g++.dg/gomp/pr67511.C | 20 ++++++++++++++++++++ 4 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/gomp/pr67511.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 1cc576a3f22..4b32f5ae383 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2015-09-10 Jakub Jelinek + + 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 PR c++/53184 diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 2a69ab0863f..5c3f1bea808 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -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, diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 140766d3ef7..fba8b155595 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,8 @@ 2015-09-10 Jakub Jelinek + 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 index 00000000000..3e0e9a388f6 --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/pr67511.C @@ -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" } + ; +} -- 2.30.2