From patchwork Wed Feb 20 22:34:03 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harald Anlauf X-Patchwork-Id: 1045591 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-496772-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=gmx.de Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="ZTPJqjdu"; 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 444XTX44y5z9s5c for ; Thu, 21 Feb 2019 09:34:23 +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 :message-id:date:from:mime-version:to:subject:content-type; q= dns; s=default; b=WOLzMxSqICKyBz20BqmgcViHjQv/z39yaL6/W1KxqYG+jI LQZlgbzdQsYpeYg1T/bTGKWKnC/5DzkN+zk8KTW9OO+QhklAYPpyD7FM1Yfj2Y6L JzAvO1pFsXTiusHd0MhWERQTH9L5vzEoe8V7VNKkP20Cy2yEhqWW7UpphPUkI= 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 :message-id:date:from:mime-version:to:subject:content-type; s= default; bh=iE3DiwOkc33rSbHfqlA46dZL6qM=; b=ZTPJqjduUNLCeoxyTXIV Sw0SQdTjBSlfWaxmPvksxcOk8AB+6GdLBaDvIclDfClI5qWJWthmYuojIPchYdON RKfpc/dIgSOVd8Co2WrrwibsPoz8+haI1R9Ha+01p09z4/YuA9ANJx1RQmHH2OAz y1leDT+EFH7LYp8ZT3PP8C8= Received: (qmail 8829 invoked by alias); 20 Feb 2019 22:34:15 -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 8797 invoked by uid 89); 20 Feb 2019 22:34:14 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-11.8 required=5.0 tests=BAYES_00, FREEMAIL_FROM, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 spammy=lun, anlauf@gmx.de, U*anlauf, anlaufgmxde X-HELO: mout.gmx.net Received: from mout.gmx.net (HELO mout.gmx.net) (212.227.17.22) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 20 Feb 2019 22:34:12 +0000 Received: from proton.at.home ([93.207.88.232]) by mail.gmx.com (mrgmx101 [212.227.17.168]) with ESMTPSA (Nemesis) id 0La3c1-1hJJGe0fvx-00lj5L; Wed, 20 Feb 2019 23:34:09 +0100 Message-ID: <5C6DD5DB.3030501@gmx.de> Date: Wed, 20 Feb 2019 23:34:03 +0100 From: Harald Anlauf User-Agent: Mozilla/5.0 (X11; Linux i686; rv:17.0) Gecko/20130329 Thunderbird/17.0.5 MIME-Version: 1.0 To: gfortran , gcc-patches Subject: [PR fortran/83057, patch] - OPEN without a filename and without STATUS='SCRATCH' could produce a warning There was a rather obvious bug in the logic for checking the arguments to the OPEN statement when NEWUNIT= was specified, which prohibited the generation of the appropriate error message. Regtested successfully. OK for trunk? Thanks, Harald 2019-02-20 Harald Anlauf PR fortran/83057 * io.c (gfc_match_open): Fix logic in checks of OPEN statement when NEWUNIT= is specified. 2019-02-20 Harald Anlauf PR fortran/83057 * gfortran.dg/newunit_6.f90: New test. Index: gcc/testsuite/gfortran.dg/newunit_6.f90 =================================================================== --- gcc/testsuite/gfortran.dg/newunit_6.f90 (nonexistent) +++ gcc/testsuite/gfortran.dg/newunit_6.f90 (working copy) @@ -0,0 +1,9 @@ +! { dg-do compile } +! +! PR fortran/83057 - OPEN without a filename and without STATUS='SCRATCH' +! could produce a warning + + open(newunit=iun,file="file") ! this is ok + open(newunit=jun,status="scratch") ! this too + open(newunit=lun) ! { dg-error "NEWUNIT specifier must have" } +end Index: gcc/fortran/io.c =================================================================== --- gcc/fortran/io.c (revision 269028) +++ gcc/fortran/io.c (working copy) @@ -2504,16 +2504,15 @@ goto cleanup; } - if (!open->file && open->status) - { - if (open->status->expr_type == EXPR_CONSTANT + if (!open->file && + (!open->status || + (open->status->expr_type == EXPR_CONSTANT && gfc_wide_strncasecmp (open->status->value.character.string, - "scratch", 7) != 0) - { + "scratch", 7) != 0))) + { gfc_error ("NEWUNIT specifier must have FILE= " "or STATUS='scratch' at %C"); goto cleanup; - } } } else if (!open->unit)