re PR fortran/77972 (ICE on broken character continuation with -Wall etc.)
authorJerry DeLisle <jvdelisle@gcc.gnu.org>
Sat, 15 Oct 2016 18:38:54 +0000 (18:38 +0000)
committerJerry DeLisle <jvdelisle@gcc.gnu.org>
Sat, 15 Oct 2016 18:38:54 +0000 (18:38 +0000)
2016-10-15  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

PR fortran/77972
* scanner.c (gfc_next_char_literal): If nextc is null do not
decrement the pointer and call the diagnostics.

PR fortran/77972
* gfortran.dg/unexpected_eof_4.f90: New test.

From-SVN: r241201

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

index a3e1f49c3f2955ae43f969a977421ded7a47baba..6dce4ebeb6a79a1579ab2d284b7607e9b028501e 100644 (file)
@@ -1,3 +1,9 @@
+2016-10-15  Jerry DeLisle  <jvdelisle@gcc.gnu.org>
+
+       PR fortran/77972
+       * scanner.c (gfc_next_char_literal): If nextc is null do not
+       decrement the pointer and call the diagnostics.
+
 2016-10-14  Andre Vehreschild  <vehre@gcc.gnu.org>
 
        * resolve.c (resolve_symbol): Add unimplemented message for
index be9c5091ea81b249dbdfe59a25cf5547c8424e7e..5e355359163768c3fde612cb10748c5d662fe9a1 100644 (file)
@@ -1414,10 +1414,9 @@ restart:
 
       if (c != '&')
        {
-         if (in_string)
+         if (in_string && gfc_current_locus.nextc)
            {
-             if (gfc_current_locus.nextc)
-               gfc_current_locus.nextc--;
+             gfc_current_locus.nextc--;
              if (warn_ampersand && in_string == INSTRING_WARN)
                gfc_warning (OPT_Wampersand, 
                             "Missing %<&%> in continued character "
index 0e48772d7983fa9397320be88a9552a912038b51..63eafa620dc1a73d7c5fdea1f5482e1a9ac1120d 100644 (file)
@@ -1,3 +1,8 @@
+2016-10-15  Jerry DeLisle  <jvdelisle@gcc.gnu.org>
+
+       PR fortran/77972
+       * gfortran.dg/unexpected_eof_4.f90: New test.
+
 2016-10-15  Janne Blomqvist  <jb@gcc.gnu.org>
 
         PR libfortran/48587
diff --git a/gcc/testsuite/gfortran.dg/unexpected_eof_4.f90 b/gcc/testsuite/gfortran.dg/unexpected_eof_4.f90
new file mode 100644 (file)
index 0000000..2832128
--- /dev/null
@@ -0,0 +1,8 @@
+! { dg-do compile }
+! { dg-options "-Wampersand" }
+! PR77972
+program p
+   character(8) :: z
+   z = 'abc&
+! { dg-error "Unterminated character constant" "" { target *-*-* } 0  }
+! { dg-error "Unexpected end of file" "" { target *-*-* } 0 }