This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] handle OpenMP/OpenACC regions inside Fortran character functions (PR85703)
- From: Cesar Philippidis <cesar_philippidis at mentor dot com>
- To: "gcc-patches at gcc dot gnu dot org" <gcc-patches at gcc dot gnu dot org>, Fortran List <fortran at gcc dot gnu dot org>, Jakub Jelinek <jakub at redhat dot com>
- Date: Wed, 13 Jun 2018 07:06:23 -0700
- Subject: [PATCH] handle OpenMP/OpenACC regions inside Fortran character functions (PR85703)
Character variables in Fortran are slightly different than reals and
integers because they can represent a single character or a string of
them. Consequently, due their nature, the Fortran resolver requires more
information to preform error checking on them.
PR85703 exposed an ICE when an OpenACC or OpenMP region is nested inside
a Fortran character function. I've isolated the problem down to the
gfc_matching_function not being reset on entry to decode_oacc_directive
or decode_omp_directive. Usually decode_statement resets that variable,
but both OpenACC and OpenMP have their own statement decoders, and
therein lies the problems. The fix is to reset gfc_matching_function
early in those functions.
Is this OK for trunk and GCC 8?
Thanks,
Cesar
2018-06-13 Cesar Philippidis <cesar@codesourcery.com>
PR fortran/85703
gcc/fortran/
* parse.c (decode_oacc_directive): Set gfc_matching_function
to false.
(decode_omp_directive): Likewise.
gcc/testsuite/
* gfortran.dg/goacc/pr85703.f90: New test.
* gfortran.dg/gomp/pr85703.f90: New test.
>From 8f763ee8aab252d1435cd0f5e32f8773722a69b1 Mon Sep 17 00:00:00 2001
From: Cesar Philippidis <cesar@codesourcery.com>
Date: Tue, 12 Jun 2018 10:32:16 -0700
Subject: [PATCH] fix pr85703
---
gcc/fortran/parse.c | 4 ++++
gcc/testsuite/gfortran.dg/goacc/pr85703.f90 | 9 +++++++++
gcc/testsuite/gfortran.dg/gomp/pr85703.f90 | 8 ++++++++
3 files changed, 21 insertions(+)
create mode 100644 gcc/testsuite/gfortran.dg/goacc/pr85703.f90
create mode 100644 gcc/testsuite/gfortran.dg/gomp/pr85703.f90
diff --git a/gcc/fortran/parse.c b/gcc/fortran/parse.c
index a3693a1..4ce6eb4 100644
--- a/gcc/fortran/parse.c
+++ b/gcc/fortran/parse.c
@@ -624,6 +624,8 @@ decode_oacc_directive (void)
gfc_clear_error (); /* Clear any pending errors. */
gfc_clear_warning (); /* Clear any pending warnings. */
+ gfc_matching_function = false;
+
if (gfc_pure (NULL))
{
gfc_error_now ("OpenACC directives at %C may not appear in PURE "
@@ -795,6 +797,8 @@ decode_omp_directive (void)
gfc_clear_error (); /* Clear any pending errors. */
gfc_clear_warning (); /* Clear any pending warnings. */
+ gfc_matching_function = false;
+
if (gfc_current_state () == COMP_FUNCTION
&& gfc_current_block ()->result->ts.kind == -1)
spec_only = true;
diff --git a/gcc/testsuite/gfortran.dg/goacc/pr85703.f90 b/gcc/testsuite/gfortran.dg/goacc/pr85703.f90
new file mode 100644
index 0000000..d9de1a3
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/goacc/pr85703.f90
@@ -0,0 +1,9 @@
+! PR fortran/85703
+! { dg-do compile }
+
+character function f()
+ !$acc parallel loop reduction(+:a)
+ do i = 1, 4
+ end do
+ !$acc end parallel loop
+end
diff --git a/gcc/testsuite/gfortran.dg/gomp/pr85703.f90 b/gcc/testsuite/gfortran.dg/gomp/pr85703.f90
new file mode 100644
index 0000000..7ca2b93
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/gomp/pr85703.f90
@@ -0,0 +1,8 @@
+! PR fortran/85703
+! { dg-do compile }
+
+character function f()
+ !$omp single
+ !$omp end single
+ f = 'a'
+end
--
2.7.4