diff options
author | Jakub Jelinek <jakub@redhat.com> | 2018-06-26 12:40:50 +0200 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2018-06-26 12:40:50 +0200 |
commit | f03915116bd2e15713cd20872f224b5ecd0a9b28 (patch) | |
tree | edb67767915f25520d780192116df84ee866174e | |
parent | 2a73b8e713c99e714c2619b2a536ce878f2f6e7e (diff) | |
download | gcc-f03915116bd2e15713cd20872f224b5ecd0a9b28.zip gcc-f03915116bd2e15713cd20872f224b5ecd0a9b28.tar.gz gcc-f03915116bd2e15713cd20872f224b5ecd0a9b28.tar.bz2 |
re PR c++/86291 (OpenMP incorrect for-loop collapsing with iterators and at least 5 nested loops)
PR c++/86291
* parser.c (cp_parser_omp_for_loop_init): Change for_block argument
type from vec<tree, va_gc> * to vec<tree, va_gc> *&.
* testsuite/libgomp.c++/pr86291.C: New test.
From-SVN: r262137
-rw-r--r-- | gcc/cp/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/cp/parser.c | 2 | ||||
-rw-r--r-- | libgomp/ChangeLog | 5 | ||||
-rw-r--r-- | libgomp/testsuite/libgomp.c++/pr86291.C | 51 |
4 files changed, 63 insertions, 1 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index aec8eb7..2123065 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2018-06-26 Jakub Jelinek <jakub@redhat.com> + + PR c++/86291 + * parser.c (cp_parser_omp_for_loop_init): Change for_block argument + type from vec<tree, va_gc> * to vec<tree, va_gc> *&. + 2018-06-23 Paolo Carlini <paolo.carlini@oracle.com> * decl.c (bad_specifiers): Add const location_t* parameter and diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 5e1b67c..a02091e 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -34917,7 +34917,7 @@ cp_parser_omp_for_incr (cp_parser *parser, tree decl) static tree cp_parser_omp_for_loop_init (cp_parser *parser, tree &this_pre_body, - vec<tree, va_gc> *for_block, + vec<tree, va_gc> *&for_block, tree &init, tree &orig_init, tree &decl, diff --git a/libgomp/ChangeLog b/libgomp/ChangeLog index 4510e08..ef0cdd0 100644 --- a/libgomp/ChangeLog +++ b/libgomp/ChangeLog @@ -1,3 +1,8 @@ +2018-06-26 Jakub Jelinek <jakub@redhat.com> + + PR c++/86291 + * testsuite/libgomp.c++/pr86291.C: New test. + 2018-06-24 Gerald Pfeifer <gerald@pfeifer.com> * libgomp.texi (Top): Move www.openmp.org to https. diff --git a/libgomp/testsuite/libgomp.c++/pr86291.C b/libgomp/testsuite/libgomp.c++/pr86291.C new file mode 100644 index 0000000..89c4b2d3 --- /dev/null +++ b/libgomp/testsuite/libgomp.c++/pr86291.C @@ -0,0 +1,51 @@ +// PR c++/86291 +// { dg-do run } +// { dg-additional-options "-std=c++11" } + +extern "C" void abort (); + +struct I +{ + using size_type = __SIZE_TYPE__; + using difference_type = __PTRDIFF_TYPE__; + using value_type = int; + using reference = int &; + using pointer = int *; + static I begin () { return I{}; } + static I end () { I res; res.pos = res.num; return res; } + I &operator++ () { ++pos; return *this; } + reference operator* () const { return val; } + I &operator+= (size_type diff) { pos += diff; return *this; } + friend bool operator< (const I &a, const I &b) { return a.pos < b.pos; } + friend difference_type operator- (const I &a, const I &b) { return a.pos - b.pos; } + size_type pos = 0; + size_type num = 1; + mutable int val = 0; +}; + +int c; + +int +main () +{ +#pragma omp parallel for collapse(10) + for (auto i = I::begin (); i < I::end (); ++i) + for (auto j = I::begin (); j < I::end (); ++j) + for (auto k = I::begin (); k < I::end (); ++k) + for (auto l = I::begin (); l < I::end (); ++l) + for (auto m = I::begin (); m < I::end (); ++m) + for (auto n = I::begin (); n < I::end (); ++n) + for (auto o = I::begin (); o < I::end (); ++o) + for (auto p = I::begin (); p < I::end (); ++p) + for (auto q = I::begin (); q < I::end (); ++q) + for (auto r = I::begin (); r < I::end (); ++r) + { + if (*i != 0 || *j != 0 || *k != 0 || *l != 0 || *m != 0 + || *n != 0 || *o != 0 || *p != 0 || *q != 0 || *r != 0) + abort (); + #pragma omp atomic + c++; + } + if (c != 1) + abort (); +} |