From patchwork Thu Oct 12 18:21:46 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Koenig X-Patchwork-Id: 825009 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-464052-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="j+WDZ5BT"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3yCfMY1Lwbz9sMN for ; Fri, 13 Oct 2017 05:22:05 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=fSMmIkX/7+aWY8Eqk50bcbMs8Wx+TyZEaVtqfnBEqHAZQr3BbL cPYaFdJjRx3J3DZayNwn12vvItFCl80BoS9PS0vzaQg+yw9e9g4eb4ykWMUgQ0nh NNScbdltsOXFLIkmCuTtK7Wp04U36DWB5wOgYIBIA2pLU+UZr1flu3wNI= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to :from:subject:message-id:date:mime-version:content-type; s= default; bh=AutUYB1okpvZk4UP8BP2K6+o290=; b=j+WDZ5BTz2DXkWmonZAQ bZFK4RPUQ2JXgc9rH4ZQYUBEcsJ+g/8XCj9aoubYlQ6ka+uL9nraOFaAA0h/ZP5u fmzmtTQoTlOyFV7bYoE8kTxcacziveQT3fBvceTUf9ihBE2CwniyNFzL1qjcxjm2 2BDMfJn+COAyZoArZS9pvk8= Received: (qmail 92950 invoked by alias); 12 Oct 2017 18:21:55 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 92926 invoked by uid 89); 12 Oct 2017 18:21:54 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.9 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_LOW, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 spammy=our X-Spam-User: qpsmtpd, 2 recipients X-HELO: cc-smtpout1.netcologne.de Received: from cc-smtpout1.netcologne.de (HELO cc-smtpout1.netcologne.de) (89.1.8.211) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 12 Oct 2017 18:21:52 +0000 Received: from cc-smtpin1.netcologne.de (cc-smtpin1.netcologne.de [89.1.8.201]) by cc-smtpout1.netcologne.de (Postfix) with ESMTP id 536E91347E; Thu, 12 Oct 2017 20:21:48 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by cc-smtpin1.netcologne.de (Postfix) with ESMTP id 5006211D75; Thu, 12 Oct 2017 20:21:48 +0200 (CEST) Received: from [78.35.132.98] (helo=cc-smtpin1.netcologne.de) by localhost with ESMTP (eXpurgate 4.1.9) (envelope-from ) id 59dfb2bc-029d-7f0000012729-7f000001b4f6-1 for ; Thu, 12 Oct 2017 20:21:48 +0200 Received: from [192.168.178.20] (xdsl-78-35-132-98.netcologne.de [78.35.132.98]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by cc-smtpin1.netcologne.de (Postfix) with ESMTPSA; Thu, 12 Oct 2017 20:21:46 +0200 (CEST) To: "fortran@gcc.gnu.org" , gcc-patches From: Thomas Koenig Subject: [patch, fortran] New take on PR 82373 Message-ID: Date: Thu, 12 Oct 2017 20:21:46 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 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 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 PR fortran/82372 * gfortran.dg/illegal_char.f90: New test. 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; }