public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Tobias Burnus <burnus@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc/devel/omp/gcc-11] openmp: Add testcase for threadprivate random access class iterators
Date: Tue,  2 Nov 2021 15:02:03 +0000 (GMT)	[thread overview]
Message-ID: <20211102150203.5C60E385843F@sourceware.org> (raw)

https://gcc.gnu.org/g:798ebb8cd58f643baa0579a631f19269a64843dd

commit 798ebb8cd58f643baa0579a631f19269a64843dd
Author: Tobias Burnus <tobias@codesourcery.com>
Date:   Tue Nov 2 15:51:22 2021 +0100

    openmp: Add testcase for threadprivate random access class iterators
    
    This adds a testcase for random access class iterators.  The diagnostics
    can be different between templates and non-templates, as for some
    threadprivate vars finish_id_expression replaces them with call to their
    corresponding wrapper, but I think it is not that big deal, we reject
    it in either case.
    
    2021-11-02  Jakub Jelinek  <jakub@redhat.com>
    
            * g++.dg/gomp/loop-8.C: New test.
    
    (cherry picked from commit fb7fee84813b23487baf0c1094860251229ab5dd)

Diff:
---
 gcc/testsuite/ChangeLog.omp        |   7 ++
 gcc/testsuite/g++.dg/gomp/loop-8.C | 128 +++++++++++++++++++++++++++++++++++++
 2 files changed, 135 insertions(+)

diff --git a/gcc/testsuite/ChangeLog.omp b/gcc/testsuite/ChangeLog.omp
index 58304e7c1fa..f0036d95396 100644
--- a/gcc/testsuite/ChangeLog.omp
+++ b/gcc/testsuite/ChangeLog.omp
@@ -1,3 +1,10 @@
+2021-11-02  Tobias Burnus  <tobias@codesourcery.com>
+
+	Backport from master:
+	2021-11-02  Jakub Jelinek  <jakub@redhat.com>
+	
+	* g++.dg/gomp/loop-8.C: New test.
+
 2021-11-02  Tobias Burnus  <tobias@codesourcery.com>
 
 	Backport from master:
diff --git a/gcc/testsuite/g++.dg/gomp/loop-8.C b/gcc/testsuite/g++.dg/gomp/loop-8.C
new file mode 100644
index 00000000000..41a1817fdd4
--- /dev/null
+++ b/gcc/testsuite/g++.dg/gomp/loop-8.C
@@ -0,0 +1,128 @@
+typedef __PTRDIFF_TYPE__ ptrdiff_t;
+
+template <typename T>
+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 <typename S> friend bool operator == (I<S> &, I<S> &);
+  template <typename S> friend bool operator == (const I<S> &, const I<S> &);
+  template <typename S> friend bool operator < (I<S> &, I<S> &);
+  template <typename S> friend bool operator < (const I<S> &, const I<S> &);
+  template <typename S> friend bool operator <= (I<S> &, I<S> &);
+  template <typename S> friend bool operator <= (const I<S> &, const I<S> &);
+  template <typename S> friend bool operator > (I<S> &, I<S> &);
+  template <typename S> friend bool operator > (const I<S> &, const I<S> &);
+  template <typename S> friend bool operator >= (I<S> &, I<S> &);
+  template <typename S> friend bool operator >= (const I<S> &, const I<S> &);
+  template <typename S> friend typename I<S>::difference_type operator - (I<S> &, I<S> &);
+  template <typename S> friend typename I<S>::difference_type operator - (const I<S> &, const I<S> &);
+  template <typename S> friend I<S> operator + (typename I<S>::difference_type , const I<S> &);
+private:
+  T *p;
+};
+
+template <typename T> bool operator == (I<T> &, I<T> &);
+template <typename T> bool operator == (const I<T> &, const I<T> &);
+template <typename T> bool operator != (I<T> &, I<T> &);
+template <typename T> bool operator != (const I<T> &, const I<T> &);
+template <typename T> bool operator < (I<T> &, I<T> &);
+template <typename T> bool operator < (const I<T> &, const I<T> &);
+template <typename T> bool operator <= (I<T> &, I<T> &);
+template <typename T> bool operator <= (const I<T> &, const I<T> &);
+template <typename T> bool operator > (I<T> &, I<T> &);
+template <typename T> bool operator > (const I<T> &, const I<T> &);
+template <typename T> bool operator >= (I<T> &, I<T> &);
+template <typename T> bool operator >= (const I<T> &, const I<T> &);
+template <typename T> typename I<T>::difference_type operator - (I<T> &, I<T> &);
+template <typename T> typename I<T>::difference_type operator - (const I<T> &, const I<T> &);
+template <typename T> I<T> operator + (typename I<T>::difference_type, const I<T> &);
+
+extern I<int> i, j;
+#pragma omp threadprivate (i, j)
+extern I<int> k, l;
+#pragma omp threadprivate (k, l)
+I<int> k, l;
+
+void
+f1 (I<int> &x, I<int> &y)
+{
+  #pragma omp for collapse(2)
+  for (i = x; i < y; i++)	// { dg-error "expected iteration declaration or initialization" }
+    for (j = x; j < y; j++)
+      ;
+}
+
+void
+f2 (I<int> &x, I<int> &y)
+{
+  #pragma omp for collapse(2)
+  for (k = x; k < y; k++)	// { dg-error "expected iteration declaration or initialization" }
+    for (l = x; l < y; l++)
+      ;
+}
+
+template <int N>
+void
+f3 (I<int> &x, I<int> &y)
+{
+  #pragma omp for collapse(2)
+  for (i = x; i < y; i++)	// { dg-error "'i' is predetermined 'threadprivate' for 'private'" }
+    for (j = x; j < y; j++)	// { dg-error "'j' is predetermined 'threadprivate' for 'private'" }
+      ;
+}
+
+template <int N>
+void
+f4 (I<int> &x, I<int> &y)
+{
+  #pragma omp for collapse(2)
+  for (k = x; k < y; k++)	// { dg-error "'k' is predetermined 'threadprivate' for 'private'" }
+    for (l = x; l < y; l++)	// { dg-error "'l' is predetermined 'threadprivate' for 'private'" }
+      ;
+}
+
+template <typename T>
+void
+f5 (I<T> &x, I<T> &y)
+{
+  #pragma omp for collapse(2)	// { dg-error "expected iteration declaration or initialization" }
+  for (i = x; i < y; i++)	// { dg-error "'i' is predetermined 'threadprivate' for 'private'" }
+    for (j = x; j < y; j++)	// { dg-error "'j' is predetermined 'threadprivate' for 'private'" }
+      ;
+}
+
+template <typename T>
+void
+f6 (I<T> &x, I<T> &y)
+{
+  #pragma omp for collapse(2)	// { dg-error "expected iteration declaration or initialization" }
+  for (k = x; k < y; k++)	// { dg-error "'k' is predetermined 'threadprivate' for 'private'" }
+    for (l = x; l < y; l++)	// { dg-error "'l' is predetermined 'threadprivate' for 'private'" }
+      ;
+}
+
+void
+test (I<int> &x, I<int> &y)
+{
+  f3<0> (x, y);
+  f4<0> (x, y);
+  f5 (x, y);
+  f6 (x, y);
+}


                 reply	other threads:[~2021-11-02 15:02 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211102150203.5C60E385843F@sourceware.org \
    --to=burnus@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).