From patchwork Sun Feb 18 04:57:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerry DeLisle X-Patchwork-Id: 874848 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-473499-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="X2Zv3GtI"; 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 3zkZPT48rYz9ryf for ; Sun, 18 Feb 2018 15:57:32 +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:cc :from:subject:message-id:date:mime-version:content-type :content-transfer-encoding; q=dns; s=default; b=MzikihzOlm8ZC8Ou tSU8YgB5/HOx3QaYxZX3Vvuaiw35ZrClhnKrgj9IGxj3NYi0k7J7lH2LKrLujwXD 44I1+cu92cW4Q/mjYb6lHehwLmQQoAzB8YDrHmSM+XCH7NK1fkFYvrWcmPyaPP2n BNC6fluHmeM56IKLKfuRMdW0hDQ= 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:cc :from:subject:message-id:date:mime-version:content-type :content-transfer-encoding; s=default; bh=V8E1qGYnnkm8bLm0BfKPot 8mRiI=; b=X2Zv3GtI23S2hKISBlSM9yoM0EWWoJ4/1LEUZXEOOZy2mTV7ey6+Ho V8ZKkDCCbBm5sDOTZlo1SnLPRvYy1NcjwbcfdSK79cw9OJxy4VWJVqKbtMGRykZU gtMOlmHHLod1bucOMAJ4MNkTkTO1GOAJVtMp4LP2HAKVYWDOHVg14= Received: (qmail 72649 invoked by alias); 18 Feb 2018 04:57:18 -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 72627 invoked by uid 89); 18 Feb 2018 04:57:14 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.9 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=jvdelisle@gcc.gnu.org, jvdelislegccgnuorg, day X-Spam-User: qpsmtpd, 2 recipients X-HELO: mtaout004-public.msg.strl.va.charter.net Received: from mtaout004-public.msg.strl.va.charter.net (HELO mtaout004-public.msg.strl.va.charter.net) (68.114.190.29) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 18 Feb 2018 04:57:12 +0000 Received: from impout002 ([68.114.189.17]) by mtaout004.msg.strl.va.charter.net (InterMail vM.9.00.023.01 201-2473-194) with ESMTP id <20180218045711.VVWD3685.mtaout004.msg.strl.va.charter.net@impout002>; Sat, 17 Feb 2018 22:57:11 -0600 Received: from amda8.localdomain ([96.41.213.35]) by impout002 with charter.net id C4xA1x0090mPCJg014xAcA; Sat, 17 Feb 2018 22:57:11 -0600 X-Authority-Analysis: v=2.2 cv=C6eZ8UH+ c=1 sm=1 tr=0 a=NNeuWy7OTYa7gJ+3pFFB5Q==:117 a=NNeuWy7OTYa7gJ+3pFFB5Q==:17 a=IkcTkHD0fZMA:10 a=x7bEGLp0ZPQA:10 a=mDV3o1hIAAAA:8 a=5cHVZlAnsfOaUo3WAQsA:9 a=QEXdDO2ut3YA:10 a=_FVE-zBwftR9WsbkzFJk:22 X-Auth-id: anZkZWxpc2xlQGNoYXJ0ZXIubmV0 To: "fortran@gcc.gnu.org" Cc: GCC Patches From: Jerry DeLisle Subject: [PATCH libgfortran] PR84412 [7/8 Regression] Erroneous "Inquire statement identifies an internal file" error Message-ID: Date: Sat, 17 Feb 2018 20:57:10 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.2 MIME-Version: 1.0 Hi all, The following patch is trivial and I plan to commit in the next day or so to trunk and gcc 7. Regression tested on x86_64-pc-gnu-linux. Regards, Jerry 2018-02-18 Jerry DeLisle PR libgfortran/84412 * io/transfer.c (finalize_transfer): After completing an internal unit I/O operation, clear internal_unit_kind. diff --git a/gcc/testsuite/gfortran.dg/inquire_18.f90 b/gcc/testsuite/gfortran.dg/inquire_18.f90 new file mode 100644 index 00000000000..9829688225b --- /dev/null +++ b/gcc/testsuite/gfortran.dg/inquire_18.f90 @@ -0,0 +1,11 @@ +! { dg-do run } +! PR84412 Wrong "Inquire statement identifies an internal file" error +program bug + implicit none + integer :: i + character(len=1) :: s + write (s,'(i1)') 0 + open(newUnit=i,file='inquire_18.txt',status='unknown') + inquire(unit=i) + close(i, status="delete") +end program bug diff --git a/libgfortran/io/transfer.c b/libgfortran/io/transfer.c index 8bc828c0214..df33bed1561 100644 --- a/libgfortran/io/transfer.c +++ b/libgfortran/io/transfer.c @@ -3993,6 +3993,10 @@ finalize_transfer (st_parameter_dt *dtp) if (dtp->u.p.unit_is_internal) { + /* The unit structure may be reused later so clear the + internal unit kind. */ + dtp->u.p.current_unit->internal_unit_kind = 0; + fbuf_destroy (dtp->u.p.current_unit); if (dtp->u.p.current_unit && (dtp->u.p.current_unit->child_dtio == 0)