public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "burnus at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug fortran/98011] [OpenACC] 'gcc/fortran/scanner.c:load_line' should consider 'flag_openacc' in addition to 'flag_openmp' (and vice versa?)?
Date: Thu, 26 Nov 2020 11:59:56 +0000	[thread overview]
Message-ID: <bug-98011-4-S8c4yAX4Dq@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-98011-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98011

--- Comment #2 from Tobias Burnus <burnus at gcc dot gnu.org> ---
Regarding OpenACC: There is something going wrong here (-fopenacc):

../testsuite/gfortran.dg/goacc/sentinel-free-form.f95:13:6:

   13 |   !$ acc parallel ! { dg-error "Unclassifiable statement" }
      |      1
Error: Unclassifiable statement at (1)

I do not understand why it parses '!$'. It should regard it as comment; that's
not OpenMP!

 * * *

I wrote (for OpenMP's conditional compilation sentinel):
> In free-form source code: "Initial lines must have a space after the sentinel".

I wonder whether checking this will break any real-world code.
Otherwise, the following patch would work.

We could also add a warning similar to the OpenACC warning:
  Warning: !$ACC at (1) starts a commented line as it neither is followed by a
space nor is a continuation line
to mitigate the real-world code issue.

--- a/gcc/fortran/scanner.c
+++ b/gcc/fortran/scanner.c
@@ -1866,10 +1866,11 @@ load_line (FILE *input, gfc_char_t **pbuf, int
*pbuflen, 

       /* For truncation and tab warnings, set seen_comment to false if one has
         either an OpenMP or OpenACC directive - or a !GCC$ attribute.  If
-        OpenMP is enabled, use '!$' as as conditional compilation sentinel
-        and OpenMP directive ('!$omp').  */
-      if (seen_comment && first_comment && flag_openmp && comment_ix + 1 == i
-         && c == '$')
+        OpenMP is enabled, use '!$' as as conditional compilation sentinel. 
*/
+      if (seen_comment && first_comment && flag_openmp
+         && ((gfc_current_form != FORM_FREE && comment_ix + 1 == i && c ==
'$')
+             || (gfc_current_form == FORM_FREE && comment_ix + 2 == i
+                 && (*pbuf)[comment_ix+1] == '$' && c == ' ')))
        first_comment = seen_comment = false;
       if (seen_comment && first_comment && comment_ix + 4 == i)
        {
@@ -1884,6 +1885,12 @@ load_line (FILE *input, gfc_char_t **pbuf, int *pbuflen, 
              && ((*pbuf)[comment_ix+3] == 'c' || (*pbuf)[comment_ix+3] == 'C')
              && (c == 'c' || c == 'C'))
            first_comment = seen_comment = false;
+         if (flag_openmp
+             && (*pbuf)[comment_ix+1] == '$'
+             && ((*pbuf)[comment_ix+2] == 'o' || (*pbuf)[comment_ix+2] == 'O')
+             && ((*pbuf)[comment_ix+3] == 'm' || (*pbuf)[comment_ix+3] == 'M')
+             && (c == 'p' || c == 'P'))
+           first_comment = seen_comment = false;
        }

       /* Vendor extension: "<tab>1" marks a continuation line.  */

  parent reply	other threads:[~2020-11-26 11:59 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-26 10:59 [Bug fortran/98011] New: " tschwinge at gcc dot gnu.org
2020-11-26 11:41 ` [Bug fortran/98011] " burnus at gcc dot gnu.org
2020-11-26 11:59 ` burnus at gcc dot gnu.org [this message]
2020-11-30 14:37 ` cvs-commit at gcc dot gnu.org
2020-11-30 14:48 ` burnus at gcc dot gnu.org
2023-10-15 21:12 ` cvs-commit at gcc dot gnu.org

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=bug-98011-4-S8c4yAX4Dq@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@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).