From: Thomas Koenig Date: Sun, 15 Oct 2017 12:00:29 +0000 (+0000) Subject: re PR fortran/82372 (Rejects valid parenthesis) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=31677224bcb5aad17f84bf717efc5f302923e47b;p=gcc.git re PR fortran/82372 (Rejects valid parenthesis) 2017-10-15 Thomas Koenig PR fortran/82372 * fortran/scanner.c (last_error_char): New global variable. (gfc_scanner_init_1): Set last_error_char to NULL. (gfc_gobble_whitespace): If a character not printable or not newline, issue an error. 2017-10-15 Thomas Koenig PR fortran/82372 * gfortran.dg/illegal_char.f90: New test. From-SVN: r253768 --- diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index ba9621fc8d5..5b003d81a99 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,11 @@ +2017-10-15 Thomas Koenig + + PR fortran/82372 + * fortran/scanner.c (last_error_char): New global variable. + (gfc_scanner_init_1): Set last_error_char to NULL. + (gfc_gobble_whitespace): If a character not printable or + not newline, issue an error. + 2017-10-13 Paul Thomas PR fortran/81048 diff --git a/gcc/fortran/scanner.c b/gcc/fortran/scanner.c index 82f431da527..49decfac52a 100644 --- a/gcc/fortran/scanner.c +++ b/gcc/fortran/scanner.c @@ -80,6 +80,7 @@ static struct gfc_file_change size_t file_changes_cur, file_changes_count; size_t file_changes_allocated; +static gfc_char_t *last_error_char; /* Functions dealing with our wide characters (gfc_char_t) and sequences of such characters. */ @@ -269,6 +270,7 @@ gfc_scanner_init_1 (void) continue_line = 0; end_flag = 0; + last_error_char = NULL; } @@ -1700,6 +1702,14 @@ gfc_gobble_whitespace (void) } while (gfc_is_whitespace (c)); + if (!ISPRINT(c) && c != '\n' && last_error_char != gfc_current_locus.nextc) + { + char buf[20]; + last_error_char = gfc_current_locus.nextc; + snprintf (buf, 20, "%2.2X", c); + gfc_error_now ("Invalid character 0x%s at %C", buf); + } + gfc_current_locus = old_loc; } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index d88bfb7e63b..d8436266a5b 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2017-10-15 Thomas Koenig + + PR fortran/82372 + * gfortran.dg/illegal_char.f90: New test. + 2017-10-14 Kyrylo Tkachov Michael Collison diff --git a/gcc/testsuite/gfortran.dg/illegal_char.f90 b/gcc/testsuite/gfortran.dg/illegal_char.f90 new file mode 100644 index 00000000000..597c7b98ddd --- /dev/null +++ b/gcc/testsuite/gfortran.dg/illegal_char.f90 @@ -0,0 +1,6 @@ +! { dg-do compile } +! PR 82372 - show hexcode of illegal, non-printable characters +program main + tmp =È 1.0 ! { dg-error "Invalid character 0xC8" } + print *,tmp +end