Fortran: Fix line-truncation warning for !$acc and !gcc$
authorTobias Burnus <tobias@codesourcery.com>
Wed, 14 Oct 2020 13:48:22 +0000 (15:48 +0200)
committerTobias Burnus <tobias@codesourcery.com>
Wed, 14 Oct 2020 13:48:22 +0000 (15:48 +0200)
gcc/fortran/ChangeLog:

PR fortran/97390
* scanner.c (load_line): Fix line-truncation warning for !$acc
and !gcc$ in free-form source code.

gcc/testsuite/ChangeLog:

PR fortran/97390
* gfortran.dg/goacc/warn_truncated.f90: New test.

gcc/fortran/scanner.c
gcc/testsuite/gfortran.dg/goacc/warn_truncated.f90 [new file with mode: 0644]

index 6f93508f9341fcee4fcfbd850c4163a521a330fa..fd11f5a244ae11dc7f943db9d3794f55f624a125 100644 (file)
@@ -1876,13 +1876,13 @@ load_line (FILE *input, gfc_char_t **pbuf, int *pbuflen, const int *first_char)
          if (((*pbuf)[comment_ix+1] == 'g' || (*pbuf)[comment_ix+1] == 'G')
              && ((*pbuf)[comment_ix+2] == 'c' || (*pbuf)[comment_ix+2] == 'C')
              && ((*pbuf)[comment_ix+3] == 'c' || (*pbuf)[comment_ix+3] == 'C')
-             && (*pbuf)[comment_ix+4] == '$')
+             && c == '$')
            first_comment = seen_comment = false;
          if (flag_openacc
              && (*pbuf)[comment_ix+1] == '$'
              && ((*pbuf)[comment_ix+2] == 'a' || (*pbuf)[comment_ix+2] == 'A')
              && ((*pbuf)[comment_ix+3] == 'c' || (*pbuf)[comment_ix+3] == 'C')
-             && ((*pbuf)[comment_ix+4] == 'c' || (*pbuf)[comment_ix+4] == 'C'))
+             && (c == 'c' || c == 'C'))
            first_comment = seen_comment = false;
        }
 
diff --git a/gcc/testsuite/gfortran.dg/goacc/warn_truncated.f90 b/gcc/testsuite/gfortran.dg/goacc/warn_truncated.f90
new file mode 100644 (file)
index 0000000..15ef3f5
--- /dev/null
@@ -0,0 +1,11 @@
+! { dg-do compile }
+! PR fortran/97390
+!
+integer :: tempRbuffer, array, compactHaloInfo, dimsizes, nHaloLayers, gpu_nList_send, gpu_idx_send, gpu_bufferOffset_send, counter
+            !$acc data present(tempRbuffer, array, compactHaloInfo, dimsizes, nHaloLayers, gpu_nList_send, gpu_idx_send, gpu_bufferOffset_send) async(counter+1)  ! { dg-error "Line truncated" }
+! { dg-error "Syntax error in Open.* variable list" "" { target "*-*-*" } .-1 }
+
+            !$acc end data  ! { dg-error "Unexpected !.ACC END DATA statement" }
+end
+
+! { dg-message "some warnings being treated as errors" "" {target "*-*-*"} 0 }