From: Ilmir Usmanov <me@ilmir.us>
To: cesar@codesourcery.com
Cc: fortran@gcc.gnu.oprg, gcc-patches@gcc.gnu.org,
"Ильмир Усманов" <i.usmanov@samsung.com>
Subject: [gomp4, fortran] Patch to fix continuation checks of OpenACC and OpenMP directives
Date: Sun, 07 Jun 2015 21:06:00 -0000 [thread overview]
Message-ID: <6770611433710899@web6g.yandex.ru> (raw)
[-- Attachment #1: Type: text/plain, Size: 202 bytes --]
Hi Cesar!
This patch fixes checks of OpenMP and OpenACC continuations in case if someone mixes them (i.e. continues OpenMP directive with !$ACC sentinel or vice versa).
OK for gomp branch?
--
Ilmir.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Fix-mix-of-OpenACC-and-OpenMP-sentinels-in-continuat.patch --]
[-- Type: text/x-diff; name="0001-Fix-mix-of-OpenACC-and-OpenMP-sentinels-in-continuat.patch", Size: 3749 bytes --]
From 5492bf5bc991b6924f5e3b35c11eeaed745df073 Mon Sep 17 00:00:00 2001
From: Ilmir Usmanov <i.usmanov@samsung.com>
Date: Sun, 7 Jun 2015 23:55:22 +0300
Subject: [PATCH] Fix mix of OpenACC and OpenMP sentinels in continuation
---
gcc/fortran/ChangeLog | 5 +++++
gcc/fortran/scanner.c | 28 ++++++++++++++++++++++++----
gcc/testsuite/ChangeLog | 5 +++++
gcc/testsuite/gfortran.dg/goacc/omp.f95 | 8 ++++++++
4 files changed, 42 insertions(+), 4 deletions(-)
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index 67f9e09..f61e0e9 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,3 +1,8 @@
+2015-06-07 Ilmir Usmanov <me@ilmir.us>
+
+ * scanner.c (gfc_next_char_literal): Fix mix of OpenACC and OpenMP
+ sentinels in continuation.
+
2015-05-05 David Malcolm <dmalcolm@redhat.com>
* expr.c (check_inquiry): Fix indentation so that it reflects the
diff --git a/gcc/fortran/scanner.c b/gcc/fortran/scanner.c
index f0e6404..5af4eea 100644
--- a/gcc/fortran/scanner.c
+++ b/gcc/fortran/scanner.c
@@ -1331,7 +1331,7 @@ restart:
continue_line = gfc_linebuf_linenum (gfc_current_locus.lb);
if (flag_openmp)
- if (prev_openmp_flag != openmp_flag)
+ if (prev_openmp_flag != openmp_flag && !openacc_flag)
{
gfc_current_locus = old_loc;
openmp_flag = prev_openmp_flag;
@@ -1340,7 +1340,7 @@ restart:
}
if (flag_openacc)
- if (prev_openacc_flag != openacc_flag)
+ if (prev_openacc_flag != openacc_flag && !openmp_flag)
{
gfc_current_locus = old_loc;
openacc_flag = prev_openacc_flag;
@@ -1359,7 +1359,7 @@ restart:
while (gfc_is_whitespace (c))
c = next_char ();
- if (openmp_flag)
+ if (openmp_flag && !openacc_flag)
{
for (i = 0; i < 5; i++, c = next_char ())
{
@@ -1370,7 +1370,7 @@ restart:
while (gfc_is_whitespace (c))
c = next_char ();
}
- if (openacc_flag)
+ if (openacc_flag && !openmp_flag)
{
for (i = 0; i < 5; i++, c = next_char ())
{
@@ -1382,6 +1382,26 @@ restart:
c = next_char ();
}
+ /* In case we have an OpenMP directive continued by OpenACC
+ sentinel, or vice versa, we get both openmp_flag and
+ openacc_flag on. */
+
+ if (openacc_flag && openmp_flag)
+ {
+ int is_openmp = 0;
+ for (i = 0; i < 5; i++, c = next_char ())
+ {
+ if (gfc_wide_tolower (c) != (unsigned char) "!$acc"[i])
+ is_openmp = 1;
+ if (i == 4)
+ old_loc = gfc_current_locus;
+ }
+ gfc_error ("Wrong %s continuation at %C: expected %s, got %s",
+ is_openmp ? "OpenACC" : "OpenMP",
+ is_openmp ? "!$ACC" : "!$OMP",
+ is_openmp ? "!$OMP" : "!$ACC");
+ }
+
if (c != '&')
{
if (in_string)
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 7c4781c..05a9a52 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2015-06-07 Ilmir Usmanov <me@ilmir.us>
+
+ * gfortran.dg/goacc/omp.f95: Add mix of OpenACC and OpenMP
+ sentinels in continuation to test.
+
2015-05-06 Yvan Roux <yvan.roux@linaro.org>
PR target/64208
diff --git a/gcc/testsuite/gfortran.dg/goacc/omp.f95 b/gcc/testsuite/gfortran.dg/goacc/omp.f95
index 24f639f..a7333eb 100644
--- a/gcc/testsuite/gfortran.dg/goacc/omp.f95
+++ b/gcc/testsuite/gfortran.dg/goacc/omp.f95
@@ -63,4 +63,12 @@ contains
!$omp end parallel
!$acc end data
end subroutine roku
+
+ subroutine nana
+ !$acc parallel &
+ !$omp do ! { dg-error "Wrong OpenACC continuation" }
+
+ !$omp parallel &
+ !$acc loop ! { dg-error "Wrong OpenMP continuation" }
+ end subroutine nana
end module test
\ No newline at end of file
--
1.9.1
next reply other threads:[~2015-06-07 21:01 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-07 21:06 Ilmir Usmanov [this message]
2015-06-07 21:40 ` Ilmir Usmanov
2015-06-08 15:01 ` Cesar Philippidis
[not found] <3008431435623821@web14j.yandex.ru>
2015-06-30 1:00 ` Ilmir Usmanov
[not found] ` <650751436268444@web22m.yandex.ru>
2015-07-14 21:24 ` Ilmir Usmanov
2015-07-14 21:26 ` Cesar Philippidis
2015-07-27 14:17 ` Thomas Schwinge
2015-10-09 10:15 ` [PR fortran/63858] Fix mix of OpenACC and OpenMP sentinels in continuations Thomas Schwinge
2015-10-19 17:12 ` Thomas Schwinge
2015-10-20 9:41 ` Jakub Jelinek
2015-11-25 14:35 ` Cesar Philippidis
2015-11-25 19:14 ` Bernhard Reutner-Fischer
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=6770611433710899@web6g.yandex.ru \
--to=me@ilmir.us \
--cc=cesar@codesourcery.com \
--cc=fortran@gcc.gnu.oprg \
--cc=gcc-patches@gcc.gnu.org \
--cc=i.usmanov@samsung.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).