From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 97596 invoked by alias); 10 Dec 2018 01:27:33 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 97578 invoked by uid 89); 10 Dec 2018 01:27:32 -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=UNIT, FILE, ACCESS 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 01:27:30 +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 wBA1RSi0081051 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Sun, 9 Dec 2018 17:27:28 -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 wBA1RSHu081050; Sun, 9 Dec 2018 17:27:28 -0800 (PST) (envelope-from sgk) Date: Mon, 10 Dec 2018 01:27:00 -0000 From: Steve Kargl To: fortran@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [Committed] PR fortran/88205 -- Check NEWUNIT after STATUS Message-ID: <20181210012728.GA81036@troutmask.apl.washington.edu> Reply-To: sgk@troutmask.apl.washington.edu MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="C7zPtVaVf+AK4Oqc" Content-Disposition: inline User-Agent: Mutt/1.10.1 (2018-07-13) X-SW-Source: 2018-12/txt/msg00554.txt.bz2 --C7zPtVaVf+AK4Oqc Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-length: 334 The attach patch moves the checks on NEWUNIT to after the checks on STATUS. 2018-12-09 Steven G. Kargl PR fortran/88205 * io.c (gfc_match_open): Move NEWUNIT checks to after STATUS checks. 2018-12-09 Steven G. Kargl PR fortran/88205 * gfortran.dg/pr88205.f90: New unit. -- Steve --C7zPtVaVf+AK4Oqc Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="pr88205.diff" Content-length: 2584 Index: gcc/fortran/io.c =================================================================== --- gcc/fortran/io.c (revision 266929) +++ gcc/fortran/io.c (working copy) @@ -2150,33 +2150,6 @@ gfc_match_open (void) warn = (open->err || open->iostat) ? true : false; - /* Checks on NEWUNIT specifier. */ - if (open->newunit) - { - if (open->unit) - { - gfc_error ("UNIT specifier not allowed with NEWUNIT at %C"); - goto cleanup; - } - - if (!open->file && open->status) - { - if (open->status->expr_type == EXPR_CONSTANT - && gfc_wide_strncasecmp (open->status->value.character.string, - "scratch", 7) != 0) - { - gfc_error ("NEWUNIT specifier must have FILE= " - "or STATUS='scratch' at %C"); - goto cleanup; - } - } - } - else if (!open->unit) - { - gfc_error ("OPEN statement at %C must have UNIT or NEWUNIT specified"); - goto cleanup; - } - /* Checks on the ACCESS specifier. */ if (open->access && open->access->expr_type == EXPR_CONSTANT) { @@ -2499,6 +2472,33 @@ gfc_match_open (void) "cannot have the value SCRATCH if a FILE specifier " "is present"); } + } + + /* Checks on NEWUNIT specifier. */ + if (open->newunit) + { + if (open->unit) + { + gfc_error ("UNIT specifier not allowed with NEWUNIT at %C"); + goto cleanup; + } + + if (!open->file && open->status) + { + if (open->status->expr_type == EXPR_CONSTANT + && gfc_wide_strncasecmp (open->status->value.character.string, + "scratch", 7) != 0) + { + gfc_error ("NEWUNIT specifier must have FILE= " + "or STATUS='scratch' at %C"); + goto cleanup; + } + } + } + else if (!open->unit) + { + gfc_error ("OPEN statement at %C must have UNIT or NEWUNIT specified"); + goto cleanup; } /* Things that are not allowed for unformatted I/O. */ Index: gcc/testsuite/gfortran.dg/pr88205.f90 =================================================================== --- gcc/testsuite/gfortran.dg/pr88205.f90 (nonexistent) +++ gcc/testsuite/gfortran.dg/pr88205.f90 (working copy) @@ -0,0 +1,14 @@ +! { dg-do compile } +! PR fortran/88205 +subroutine s1 + real, parameter :: status = 0 + open (newunit=n, status=status) ! { dg-error "STATUS requires" } +end +subroutine s2 + complex, parameter :: status = 0 + open (newunit=n, status=status) ! { dg-error "STATUS requires" } +end +program p + logical, parameter :: status = .false. + open (newunit=a, status=status) ! { dg-error "STATUS requires" } +end --C7zPtVaVf+AK4Oqc--