From: Julian Brown <julian@codesourcery.com>
To: <gcc-patches@gcc.gnu.org>
Cc: <fortran@gcc.gnu.org>, Tobias Burnus <tobias@codesourcery.com>
Subject: [PATCH 4/7] [og10] Fortran: OpenMP/OpenACC diagnose substring rejections better
Date: Wed, 24 Feb 2021 13:57:25 -0800 [thread overview]
Message-ID: <20210224215726.129681-5-julian@codesourcery.com> (raw)
In-Reply-To: <20210224215726.129681-1-julian@codesourcery.com>
From: Tobias Burnus <tobias@codesourcery.com>
gcc/fortran/ChangeLog:
* openmp.c (resolve_omp_clauses): Explicitly diagnose
substrings as not permitted.
gcc/testsuite/ChangeLog:
* gfortran.dg/goacc/substring.f90: New test.
* gfortran.dg/gomp/substring.f90: New test.
(cherry picked from commit f0e618faeb619ec02dabbef203a5575fca44a7f7)
---
gcc/fortran/ChangeLog.omp | 7 +++++
gcc/fortran/openmp.c | 8 +++++-
gcc/testsuite/ChangeLog.omp | 7 +++++
gcc/testsuite/gfortran.dg/goacc/substring.f90 | 27 +++++++++++++++++++
gcc/testsuite/gfortran.dg/gomp/substring.f90 | 22 +++++++++++++++
5 files changed, 70 insertions(+), 1 deletion(-)
create mode 100644 gcc/testsuite/gfortran.dg/goacc/substring.f90
create mode 100644 gcc/testsuite/gfortran.dg/gomp/substring.f90
diff --git a/gcc/fortran/ChangeLog.omp b/gcc/fortran/ChangeLog.omp
index 2dd82a70cb71..09c2bb855c88 100644
--- a/gcc/fortran/ChangeLog.omp
+++ b/gcc/fortran/ChangeLog.omp
@@ -1,3 +1,10 @@
+2021-02-24 Tobias Burnus <tobias@codesourcery.com>
+
+ Backport from mainline
+
+ * openmp.c (resolve_omp_clauses): Explicitly diagnose
+ substrings as not permitted.
+
2021-02-24 Julian Brown <julian@codesourcery.com>
Backport from mainline
diff --git a/gcc/fortran/openmp.c b/gcc/fortran/openmp.c
index 61a340d7f396..a7592f0545d9 100644
--- a/gcc/fortran/openmp.c
+++ b/gcc/fortran/openmp.c
@@ -4978,7 +4978,13 @@ resolve_omp_clauses (gfc_code *code, gfc_omp_clauses *omp_clauses,
|| (n->expr
&& (!resolved || n->expr->expr_type != EXPR_VARIABLE)))
{
- if (!resolved
+ if (array_ref
+ && (array_ref->type == REF_SUBSTRING
+ || (array_ref->next
+ && array_ref->next->type == REF_SUBSTRING)))
+ gfc_error ("Unexpected substring reference in %s clause "
+ "at %L", name, &n->where);
+ else if (!resolved
|| n->expr->expr_type != EXPR_VARIABLE
|| array_ref->next
|| array_ref->type != REF_ARRAY)
diff --git a/gcc/testsuite/ChangeLog.omp b/gcc/testsuite/ChangeLog.omp
index e04a4ee3ebff..d012e9e75b4e 100644
--- a/gcc/testsuite/ChangeLog.omp
+++ b/gcc/testsuite/ChangeLog.omp
@@ -1,3 +1,10 @@
+2021-02-24 Tobias Burnus <tobias@codesourcery.com>
+
+ Backport from mainline
+
+ * gfortran.dg/goacc/substring.f90: New test.
+ * gfortran.dg/gomp/substring.f90: New test.
+
2021-02-24 Julian Brown <julian@codesourcery.com>
Backport from mainline
diff --git a/gcc/testsuite/gfortran.dg/goacc/substring.f90 b/gcc/testsuite/gfortran.dg/goacc/substring.f90
new file mode 100644
index 000000000000..25031daddf33
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/goacc/substring.f90
@@ -0,0 +1,27 @@
+implicit none
+character(len=10) :: str1, str2(5,5)
+
+type t
+ character(len=10) :: str1, str2(5,5)
+end type t
+type(t) :: v
+
+!$acc enter data copyin(v%str1) ! OK
+!$acc enter data copyin(v%str2) ! OK
+!$acc enter data copyin(v%str2(1,2)) ! OK
+!$acc enter data copyin(str1) ! OK
+!$acc enter data copyin(str2) ! OK
+!$acc enter data copyin(str2(1,2)) ! OK
+
+!$acc enter data copyin(v%str1(2:5)) ! { dg-error "Unexpected substring reference in MAP clause" }
+!$acc enter data copyin(v%str2(1,2)(2:4)) ! { dg-error "Unexpected substring reference in MAP clause" }
+!$acc enter data copyin(str1(2:5)) ! { dg-error "Unexpected substring reference in MAP clause" }
+!$acc enter data copyin(str2(1,2)(2:4)) ! { dg-error "Unexpected substring reference in MAP clause" }
+
+!$acc parallel
+!$acc update host(v%str1(2:5)) ! { dg-error "Unexpected substring reference in MAP clause" }
+!$acc update host(v%str2(1,2)(2:4)) ! { dg-error "Unexpected substring reference in MAP clause" }
+!$acc update host(str1(2:5)) ! { dg-error "Unexpected substring reference in MAP clause" }
+!$acc update host(str2(1,2)(2:4)) ! { dg-error "Unexpected substring reference in MAP clause" }
+!$acc end parallel
+end
diff --git a/gcc/testsuite/gfortran.dg/gomp/substring.f90 b/gcc/testsuite/gfortran.dg/gomp/substring.f90
new file mode 100644
index 000000000000..23d7fb7e48ab
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/gomp/substring.f90
@@ -0,0 +1,22 @@
+implicit none
+character(len=10) :: str1, str2(5,5)
+
+type t
+ character(len=10) :: str1, str2(5,5)
+end type t
+type(t) :: v
+
+!$omp target enter data map(to: str1) ! OK
+!$omp target enter data map(to: str2) ! OK
+!$omp target enter data map(to: str2(2,5)) ! OK
+
+!$omp target enter data map(to: str1(2,5)) ! { dg-error "Syntax error in OpenMP variable list" }
+!$omp target enter data map(to: str2(1,2)(2:4)) ! { dg-error "Unexpected substring reference in MAP clause" }
+
+!$omp target enter data map(to: v%str1) ! OK
+!$omp target enter data map(to: v%str2) ! OK
+!$omp target enter data map(to: v%str2(1,2)) ! OK
+
+!$omp target enter data map(to: v%str1(2:5)) ! { dg-error "Unexpected substring reference in MAP clause" }
+!$omp target enter data map(to: v%str2(1,2)(2:4)) ! { dg-error "Unexpected substring reference in MAP clause" }
+end
--
2.29.2
next prev parent reply other threads:[~2021-02-24 21:57 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-24 21:57 [PATCH 0/7] [og10] openacc: Arrays/derived types/character type backports Julian Brown
2021-02-24 21:57 ` [PATCH 1/7] [og10] openacc: Dereference BT_CLASS data pointers but not BT_DERIVED pointers Julian Brown
2021-02-24 21:57 ` [PATCH 2/7] [og10] openacc: Use class_pointer instead of pointer attribute for class types Julian Brown
2021-02-24 21:57 ` [PATCH 3/7] [og10] openacc: Character types and mixed arrays/derived type tests Julian Brown
2021-02-24 21:57 ` Julian Brown [this message]
2021-02-25 15:30 ` [OG10] backport an additional commit – was: [PATCH 0/7] [og10] openacc: Arrays/derived types/character type backports Tobias Burnus
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=20210224215726.129681-5-julian@codesourcery.com \
--to=julian@codesourcery.com \
--cc=fortran@gcc.gnu.org \
--cc=gcc-patches@gcc.gnu.org \
--cc=tobias@codesourcery.com \
/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).