From 4aa9742252ea419947fe32ff64c7546c92286b96 Mon Sep 17 00:00:00 2001 From: Tobias Burnus Date: Wed, 14 Oct 2020 15:48:22 +0200 Subject: [PATCH] Fortran: Fix line-truncation warning for !$acc and !gcc$ 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 | 4 ++-- gcc/testsuite/gfortran.dg/goacc/warn_truncated.f90 | 11 +++++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/gfortran.dg/goacc/warn_truncated.f90 diff --git a/gcc/fortran/scanner.c b/gcc/fortran/scanner.c index 6f93508f934..fd11f5a244a 100644 --- a/gcc/fortran/scanner.c +++ b/gcc/fortran/scanner.c @@ -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 index 00000000000..15ef3f513ae --- /dev/null +++ b/gcc/testsuite/gfortran.dg/goacc/warn_truncated.f90 @@ -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 } -- 2.30.2