From patchwork Mon Dec 10 20:05:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Kargl X-Patchwork-Id: 1010657 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-492024-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=troutmask.apl.washington.edu Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="Yu5yrAtP"; 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 43DDbP6BMsz9s3l for ; Tue, 11 Dec 2018 07:05:52 +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:date :from:to:subject:message-id:reply-to:mime-version:content-type; q=dns; s=default; b=LUc1SKPuC7cKi979amz4CGbHAyVHSGtmjQb1w9qtKE/ NFR7x7sNfqAqLDPmDMJoMj5SnBd5z9dqX/undO057eDgBKgwC6/x8g2GAap6IWLa cPE9ApH1s3Gh5NNxwgarbotcf3Ik72X1hifQxf4COBNL1qyxKYyjtkRuZOIuMIXw = 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:date :from:to:subject:message-id:reply-to:mime-version:content-type; s=default; bh=r4iC90L3TIdU20blJVz8CRNysYY=; b=Yu5yrAtPrfdyZO9KP 43nfLXqXO/5gUclfh786UDU8ZUIOVYqXwqQcXXp508/x97SSEhkk6w/e85sAOGEU hLqlJNIhUrc5FA4yH7w4EYVdhTM4XsGtGK5NNJBIVn4hJSLFcIXaIDT6/qLfLgFa czGIK5lbKbzSyyw31laeEzf9H8= Received: (qmail 40053 invoked by alias); 10 Dec 2018 20:05:44 -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 40013 invoked by uid 89); 10 Dec 2018 20:05:43 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-10.1 required=5.0 tests=BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, KAM_LAZY_DOMAIN_SECURITY autolearn=ham version=3.3.2 spammy=msg, match_error, MATCH_ERROR X-HELO: troutmask.apl.washington.edu Received: from troutmask.apl.washington.edu (HELO troutmask.apl.washington.edu) (128.95.76.21) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 10 Dec 2018 20:05:42 +0000 Received: from troutmask.apl.washington.edu (localhost [127.0.0.1]) by troutmask.apl.washington.edu (8.15.2/8.15.2) with ESMTPS id wBAK5eh9005991 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Mon, 10 Dec 2018 12:05:40 -0800 (PST) (envelope-from sgk@troutmask.apl.washington.edu) Received: (from sgk@localhost) by troutmask.apl.washington.edu (8.15.2/8.15.2/Submit) id wBAK5eU8005990; Mon, 10 Dec 2018 12:05:40 -0800 (PST) (envelope-from sgk) Date: Mon, 10 Dec 2018 12:05:40 -0800 From: Steve Kargl To: fortran@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [Committed] PR fortran/88269 -- Check for missing UNIT/NEWUNIT Message-ID: <20181210200540.GA5946@troutmask.apl.washington.edu> Reply-To: sgk@troutmask.apl.washington.edu MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.10.1 (2018-07-13) The attach patch has been coommitted to 7-branch, 8-branch, and trunk after successful regression testing. 2018-12-10 Steven G. Kargl PR fortran/88269 * io.c (io_constraint): Update macro. If locus line buffer is NULL, use gfc_current_locus in error messages. (check_io_constraints): Catch missing IO UNIT in write and read statements. io_constraint macro is incompatible here. 2018-12-10 Steven G. Kargl PR fortran/88269 * gfortran.dg/pr88269.f90: New test. Index: gcc/fortran/io.c =================================================================== --- gcc/fortran/io.c (revision 266958) +++ gcc/fortran/io.c (working copy) @@ -3678,10 +3678,13 @@ static match check_io_constraints (io_kind k, gfc_dt *dt, gfc_code *io_code, locus *spec_end) { -#define io_constraint(condition,msg,arg)\ +#define io_constraint(condition, msg, arg)\ if (condition) \ {\ - gfc_error(msg,arg);\ + if ((arg)->lb != NULL)\ + gfc_error ((msg), (arg));\ + else\ + gfc_error ((msg), &gfc_current_locus);\ m = MATCH_ERROR;\ } @@ -3741,11 +3744,14 @@ if (condition) \ if (expr && expr->ts.type != BT_CHARACTER) { - io_constraint (gfc_pure (NULL) && (k == M_READ || k == M_WRITE), - "IO UNIT in %s statement at %C must be " + if (gfc_pure (NULL) && (k == M_READ || k == M_WRITE)) + { + gfc_error ("IO UNIT in %s statement at %C must be " "an internal file in a PURE procedure", io_kind_name (k)); - + return MATCH_ERROR; + } + if (k == M_READ || k == M_WRITE) gfc_unset_implicit_pure (NULL); } Index: gcc/testsuite/gfortran.dg/pr88269.f90 =================================================================== --- gcc/testsuite/gfortran.dg/pr88269.f90 (nonexistent) +++ gcc/testsuite/gfortran.dg/pr88269.f90 (working copy) @@ -0,0 +1,6 @@ +! { dg-do compile } +! PR fortran/88269 +program p + write (end=1e1) ! { dg-error "tag not allowed" } +end +