From: Thomas Koenig <tkoenig@netcologne.de>
To: "fortran@gcc.gnu.org" <fortran@gcc.gnu.org>,
gcc-patches <gcc-patches@gcc.gnu.org>
Subject: [patch, fortran] New take on PR 82373
Date: Thu, 12 Oct 2017 18:21:00 -0000 [thread overview]
Message-ID: <e3e1da07-0dce-d198-3694-7040bd2febe4@netcologne.de> (raw)
[-- Attachment #1: Type: text/plain, Size: 769 bytes --]
Hello world,
after some thought, I think the PR can be fixed by something
far less invasive than my previous patch.
The new version of the patch simply issues an error for a
non-printable character (which should never be legal).
Anything else should be caught by other error reporting
routines.
OK for trunk?
Regards
Thomas
2017-10-12 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/82372
* fortran/scanner.c (last_error_char): New global variable.
(gfc_scanner_init_1): Set last_error_char to NULL.
(gfc_gooble_whitespace): If a character not printable or
not newline, issue an error.
2017-10-12 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/82372
* gfortran.dg/illegal_char.f90: New test.
[-- Attachment #2: p2.diff --]
[-- Type: text/x-patch, Size: 933 bytes --]
Index: scanner.c
===================================================================
--- scanner.c (Revision 253530)
+++ scanner.c (Arbeitskopie)
@@ -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;
}
[-- Attachment #3: illegal_char_2.f90 --]
[-- Type: text/x-fortran, Size: 28 bytes --]
#include "illegal_char.f90"
next reply other threads:[~2017-10-12 18:21 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-12 18:21 Thomas Koenig [this message]
2017-10-12 19:26 ` Steve Kargl
2017-10-15 12:14 ` Thomas Koenig
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=e3e1da07-0dce-d198-3694-7040bd2febe4@netcologne.de \
--to=tkoenig@netcologne.de \
--cc=fortran@gcc.gnu.org \
--cc=gcc-patches@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).