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

Jerry DeLisle <jvdelisle at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jvdelisle at gcc dot gnu.org

--- Comment #1 from Jerry DeLisle <jvdelisle at gcc dot gnu.org> ---
With this patch:

diff --git a/gcc/fortran/scanner.c b/gcc/fortran/scanner.c
index 6a7a5b68..be9c5091 100644
--- a/gcc/fortran/scanner.c
+++ b/gcc/fortran/scanner.c
@@ -1416,7 +1416,8 @@ restart:
        {
          if (in_string)
            {
-             gfc_current_locus.nextc--;
+             if (gfc_current_locus.nextc)
+               gfc_current_locus.nextc--;
              if (warn_ampersand && in_string == INSTRING_WARN)
                gfc_warning (OPT_Wampersand, 
                             "Missing %<&%> in continued character "
@@ -1427,7 +1428,10 @@ restart:
          /* Both !$omp and !$ -fopenmp continuation lines have & on the
             continuation line only optionally.  */
          else if (openmp_flag || openacc_flag || openmp_cond_flag)
-           gfc_current_locus.nextc--;
+           {
+             if (gfc_current_locus.nextc)
+                 gfc_current_locus.nextc--;
+           }
          else
            {
              c = ' ';


I get:

$ gfc bug1.f90 
bug1.f90:3:8:

    z = 'abc&
        1
Error: Unterminated character constant beginning at (1)
f951: Error: Unexpected end of file in ‘bug1.f90’
$ gfc bug2.f90 
bug2.f90:2:24:

    character(8) :: z = 'abc&
                        1
Error: Unterminated character constant beginning at (1)
f951: Error: Unexpected end of file in ‘bug2.f90’

Reply via email to