[Bug c++/95197] libgomp/testsuite/libgomp.c++/for-27.C fails with -std=c++17

2020-06-14 Thread cvs-commit at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95197

--- Comment #5 from CVS Commits  ---
The releases/gcc-10 branch has been updated by Jakub Jelinek
:

https://gcc.gnu.org/g:6d6df84dc031924cb95599a6c498aa27d3bceac4

commit r10-8294-g6d6df84dc031924cb95599a6c498aa27d3bceac4
Author: Jakub Jelinek 
Date:   Tue May 26 09:35:21 2020 +0200

openmp: Ensure copy ctor for composite distribute parallel for class
iterators is instantiated [PR95197]

During gimplification omp_finish_clause langhook is called in several
places
to add the language specific info to the clause like what default/copy
ctors,
dtors and assignment operators should be used.

Unfortunately, if it refers to some not yet instantiated method, during
gimplification it is too late and the methods will not be instantiated
anymore.  For other cases, the genericizer has code to detect those and
instantiate whatever is needed, this change adds the same for
distribute parallel for class iterators where we under the hood need
a copy constructor for the iterator to implement it.

2020-05-26  Jakub Jelinek  

PR c++/95197
* gimplify.c (find_combined_omp_for): Move to omp-general.c.
* omp-general.h (find_combined_omp_for): Declare.
* omp-general.c: Include tree-iterator.h.
(find_combined_omp_for): New function, moved from gimplify.c.

* cp-gimplify.c: Include omp-general.h.
(cp_genericize_r) : For class iteration
variables in composite distribute parallel for, instantiate copy
ctor of their types.

(cherry picked from commit f1f862aec2c3b93dbd6adfc35b0e1b6034e59c21)

[Bug c++/95197] libgomp/testsuite/libgomp.c++/for-27.C fails with -std=c++17

2020-05-26 Thread cvs-commit at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95197

--- Comment #4 from CVS Commits  ---
The master branch has been updated by Jakub Jelinek :

https://gcc.gnu.org/g:f1f862aec2c3b93dbd6adfc35b0e1b6034e59c21

commit r11-629-gf1f862aec2c3b93dbd6adfc35b0e1b6034e59c21
Author: Jakub Jelinek 
Date:   Tue May 26 09:35:21 2020 +0200

openmp: Ensure copy ctor for composite distribute parallel for class
iterators is instantiated [PR95197]

During gimplification omp_finish_clause langhook is called in several
places
to add the language specific info to the clause like what default/copy
ctors,
dtors and assignment operators should be used.

Unfortunately, if it refers to some not yet instantiated method, during
gimplification it is too late and the methods will not be instantiated
anymore.  For other cases, the genericizer has code to detect those and
instantiate whatever is needed, this change adds the same for
distribute parallel for class iterators where we under the hood need
a copy constructor for the iterator to implement it.

2020-05-26  Jakub Jelinek  

PR c++/95197
* gimplify.c (find_combined_omp_for): Move to omp-general.c.
* omp-general.h (find_combined_omp_for): Declare.
* omp-general.c: Include tree-iterator.h.
(find_combined_omp_for): New function, moved from gimplify.c.

* cp-gimplify.c: Include omp-general.h.
(cp_genericize_r) : For class iteration
variables in composite distribute parallel for, instantiate copy
ctor of their types.

[Bug c++/95197] libgomp/testsuite/libgomp.c++/for-27.C fails with -std=c++17

2020-05-25 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95197

Jakub Jelinek  changed:

   What|Removed |Added

 Status|UNCONFIRMED |ASSIGNED
   Assignee|unassigned at gcc dot gnu.org  |jakub at gcc dot gnu.org
 Ever confirmed|0   |1
   Last reconfirmed||2020-05-25

--- Comment #3 from Jakub Jelinek  ---
Created attachment 48597
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=48597&action=edit
gcc11-pr95197.patch

Untested fix.

[Bug c++/95197] libgomp/testsuite/libgomp.c++/for-27.C fails with -std=c++17

2020-05-25 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95197

--- Comment #2 from Jakub Jelinek  ---
Reduced testcase:

// { dg-do link }

typedef __PTRDIFF_TYPE__ ptrdiff_t;

template 
class I
{
public:
  typedef ptrdiff_t difference_type;
  I ();
  ~I ();
  I (T *);
  I (const I &);
  T &operator * ();
  T *operator -> ();
  T &operator [] (const difference_type &) const;
  I &operator = (const I &);
  I &operator ++ ();
  I operator ++ (int);
  I &operator -- ();
  I operator -- (int);
  I &operator += (const difference_type &);
  I &operator -= (const difference_type &);
  I operator + (const difference_type &) const;
  I operator - (const difference_type &) const;
  template  friend bool operator == (I &, I &);
  template  friend bool operator == (const I &, const I &);
  template  friend bool operator < (I &, I &);
  template  friend bool operator < (const I &, const I &);
  template  friend bool operator <= (I &, I &);
  template  friend bool operator <= (const I &, const I &);
  template  friend bool operator > (I &, I &);
  template  friend bool operator > (const I &, const I &);
  template  friend bool operator >= (I &, I &);
  template  friend bool operator >= (const I &, const I &);
  template  friend typename I::difference_type operator - (I
&, I &);
  template  friend typename I::difference_type operator - (const
I &, const I &);
  template  friend I operator + (typename I::difference_type
, const I &);
private:
  T *p;
};
template  I::I () : p (0) {}
template  I::~I () {}
template  I::I (T *x) : p (x) {}
template  I::I (const I &x) : p (x.p) {}
template  T &I::operator * () { return *p; }
template  T *I::operator -> () { return p; }
template  T &I::operator [] (const difference_type &x) const {
return p[x]; }
template  I &I::operator = (const I &x) { p = x.p; return
*this; }
template  I &I::operator ++ () { ++p; return *this; }
template  I I::operator ++ (int) { return I (p++); }
template  I &I::operator -- () { --p; return *this; }
template  I I::operator -- (int) { return I (p--); }
template  I &I::operator += (const difference_type &x) { p +=
x; return *this; }
template  I &I::operator -= (const difference_type &x) { p -=
x; return *this; }
template  I I::operator + (const difference_type &x) const {
return I (p + x); }
template  I I::operator - (const difference_type &x) const {
return I (p - x); }
template  bool operator == (I &x, I &y) { return x.p == y.p;
}
template  bool operator == (const I &x, const I &y) { return
x.p == y.p; }
template  bool operator != (I &x, I &y) { return !(x == y); }
template  bool operator != (const I &x, const I &y) { return
!(x == y); }
template  bool operator < (I &x, I &y) { return x.p < y.p; }
template  bool operator < (const I &x, const I &y) { return
x.p < y.p; }
template  bool operator <= (I &x, I &y) { return x.p <= y.p;
}
template  bool operator <= (const I &x, const I &y) { return
x.p <= y.p; }
template  bool operator > (I &x, I &y) { return x.p > y.p; }
template  bool operator > (const I &x, const I &y) { return
x.p > y.p; }
template  bool operator >= (I &x, I &y) { return x.p >= y.p;
}
template  bool operator >= (const I &x, const I &y) { return
x.p >= y.p; }
template  typename I::difference_type operator - (I &x, I
&y) { return x.p - y.p; }
template  typename I::difference_type operator - (const I &x,
const I &y) { return x.p - y.p; }
template  I operator + (typename I::difference_type x, const
I &y) { return I (x + y.p); }

void
bar (I &a)
{
}

void
foo (const I &a, const I &b)
{
  I i;
  #pragma omp distribute parallel for
  for (i = a; i < b; i++)
bar (i);
}

int
main ()
{
  int a[64];
  foo (&a[0], &a[63]);
}

[Bug c++/95197] libgomp/testsuite/libgomp.c++/for-27.C fails with -std=c++17

2020-05-25 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95197

--- Comment #1 from Jakub Jelinek  ---
For e.g.
void bar (I &a);

void
foo (I &a)
{
  #pragma omp task //firstprivate (a)
  bar (a);
}
with the same templates this is handled by omp_cxx_notice_variable, which will
1068  get_copy_ctor (type, tf_none);
1069  get_dtor (type, tf_none);
because when it is done only during gimplification, we don't instantiate it
anymore.
So, I think I need to go through all the lang_hooks.decls.omp_finish_clause
calls in the gimplifier and deal with it similarly during genericization time.