public inbox for fortran@gcc.gnu.org
 help / color / mirror / Atom feed
* Fortran: With OpenACC, ignore OpenMP's cond comp sentinels
@ 2020-11-27 17:18 Tobias Burnus
  2020-11-27 17:31 ` Jakub Jelinek
  0 siblings, 1 reply; 4+ messages in thread
From: Tobias Burnus @ 2020-11-27 17:18 UTC (permalink / raw)
  To: gcc-patches, fortran, Thomas Schwinge

[-- Attachment #1: Type: text/plain, Size: 602 bytes --]

'!' starts in Fortran a comment (+ fixed-form variants)
OpenACC defines as sentinel "!$acc" (likewise)
But OpenMP has two: Besides "!$omp" there is additionally
"!$ " (with space) to permit conditional compilation.

Currently, -fopenacc also executes the '!$ ' code, which I
think does not make sense.

Hence, this patch ignores it.
Comments? If not, I intent to commit it in the next days

Tobias

-----------------
Mentor Graphics (Deutschland) GmbH, Arnulfstraße 201, 80634 München / Germany
Registergericht München HRB 106955, Geschäftsführer: Thomas Heurung, Alexander Walter

[-- Attachment #2: oacc-scanner.diff --]
[-- Type: text/x-patch, Size: 2186 bytes --]

Fortran: With OpenACC, ignore OpenMP's cond comp sentinels

gcc/fortran/ChangeLog:

	PR fortran/98011
	* scanner.c (skip_free_comments): If only -fopenacc but not -fopenmp
	is used, ignore OpenMP's conditional compilation sentinels.

gcc/testsuite/ChangeLog:

	PR fortran/98011
	* gfortran.dg/goacc/sentinel-free-form.f95: Update as OpenMP's "!$ "
	conditional compilation sentinels are now ignored.

 gcc/fortran/scanner.c                              | 23 ++++++++--------------
 .../gfortran.dg/goacc/sentinel-free-form.f95       |  7 +++++--
 2 files changed, 13 insertions(+), 17 deletions(-)

diff --git a/gcc/fortran/scanner.c b/gcc/fortran/scanner.c
index fd11f5a244a..b70728d6bd1 100644
--- a/gcc/fortran/scanner.c
+++ b/gcc/fortran/scanner.c
@@ -899,21 +899,14 @@ skip_free_comments (void)
 		if (next_char () == '$')
 		  {
 		    c = next_char ();
-		      if (c == 'a' || c == 'A')
-			{
-			  if (skip_free_oacc_sentinel (start, old_loc))
-			    return false;
-			  gfc_current_locus = old_loc;
-			  next_char();
-			  c = next_char();
-			}
-		      if (continue_flag || c == ' ' || c == '\t')
-			{
-			  gfc_current_locus = old_loc;
-			  next_char();
-			  openacc_flag = 0;
-			  return true;
-			}
+		    if (c == 'a' || c == 'A')
+		      {
+			if (skip_free_oacc_sentinel (start, old_loc))
+			  return false;
+			gfc_current_locus = old_loc;
+			next_char();
+			c = next_char();
+		      }
 		  }
 		gfc_current_locus = old_loc;
 	      }
diff --git a/gcc/testsuite/gfortran.dg/goacc/sentinel-free-form.f95 b/gcc/testsuite/gfortran.dg/goacc/sentinel-free-form.f95
index 1a3189cb34e..00dac667ef1 100644
--- a/gcc/testsuite/gfortran.dg/goacc/sentinel-free-form.f95
+++ b/gcc/testsuite/gfortran.dg/goacc/sentinel-free-form.f95
@@ -10,7 +10,10 @@ program test
   x = 0.0 !$acc parallel ! comment
   ! sentinel must appear as a single word
   ! $acc parallel ! comment
-  !$ acc parallel ! { dg-error "Unclassifiable statement" }
+
+  ! note that '!$ ' is OpenMP's conditional compilation sentinel
+  !$ acc ignored_due_to_space  ! comment
+
   ! directive lines must have space after sentinel
   !$accparallel ! { dg-warning "followed by a space" }
   do i = 1,10

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-11-30 14:39 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-27 17:18 Fortran: With OpenACC, ignore OpenMP's cond comp sentinels Tobias Burnus
2020-11-27 17:31 ` Jakub Jelinek
2020-11-27 22:14   ` Fortran: With OpenACC, ignore OpenMP's cond comp sentinels [PR98011] Tobias Burnus
2020-11-30 14:39     ` Tobias Burnus

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).