From 523ee218bbdc17a0cd1137e20671d73da990d329 Mon Sep 17 00:00:00 2001 From: Jerry DeLisle Date: Sat, 15 Oct 2016 18:38:54 +0000 Subject: [PATCH] re PR fortran/77972 (ICE on broken character continuation with -Wall etc.) 2016-10-15 Jerry DeLisle 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 | 6 ++++++ gcc/fortran/scanner.c | 5 ++--- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gfortran.dg/unexpected_eof_4.f90 | 8 ++++++++ 4 files changed, 21 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/gfortran.dg/unexpected_eof_4.f90 diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index a3e1f49c3f2..6dce4ebeb6a 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2016-10-15 Jerry DeLisle + + 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 * resolve.c (resolve_symbol): Add unimplemented message for diff --git a/gcc/fortran/scanner.c b/gcc/fortran/scanner.c index be9c5091ea8..5e355359163 100644 --- a/gcc/fortran/scanner.c +++ b/gcc/fortran/scanner.c @@ -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 " diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 0e48772d798..63eafa620dc 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2016-10-15 Jerry DeLisle + + PR fortran/77972 + * gfortran.dg/unexpected_eof_4.f90: New test. + 2016-10-15 Janne Blomqvist 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 index 00000000000..2832128e6d6 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/unexpected_eof_4.f90 @@ -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 } -- 2.30.2