From patchwork Sat Jan 19 18:31:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Kargl X-Patchwork-Id: 1028008 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-494362-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="s5gt8tSI"; 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 43hmcF396Kz9s7h for ; Sun, 20 Jan 2019 05:31:39 +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=tcGUY3VdDtqk99Ag3Gb72JVBg5rWWqbfNWvRoAbVacZ G2zgvytYN6hT668ZfadAmfmQI/CiY5kqY1fZIcDpkFhVWgKAsxZySHvEw2bsrbNj HCO3TB3PLvrelELLPg/GCiIRhNoIYGdk0uu6b+vocN9KOGtkbXlBhC07rF2XR2SA = 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=+B99RAmK5qXEz4+IxJLSAdxwjm8=; b=s5gt8tSIuGser+snt lyyfzBDL9pVxBgRKg/MFJFrmwSFrEYY6wkJcIFo6twLHY1nOHCN1+wBmzN4H7fzN WfEcTkCGg3YjRjma3peaJwm91h5s5rLFLsGxyLkird3zwVXxNG288Lj5oeuCwuqO fKI1AXwyGNlkHYNY7BI5Tlesug= Received: (qmail 6619 invoked by alias); 19 Jan 2019 18:31:29 -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 6562 invoked by uid 89); 19 Jan 2019 18:31:27 -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=H*MI:edu 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; Sat, 19 Jan 2019 18:31:24 +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 x0JIVMuF013759 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Sat, 19 Jan 2019 10:31:22 -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 x0JIVLgI013758; Sat, 19 Jan 2019 10:31:21 -0800 (PST) (envelope-from sgk) Date: Sat, 19 Jan 2019 10:31:21 -0800 From: Steve Kargl To: fortran@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [PATCH] PR fortran/77960 -- inpute-item can't be function Message-ID: <20190119183121.GA13742@troutmask.apl.washington.edu> Reply-To: sgk@troutmask.apl.washington.edu MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.11.2 (2019-01-07) The attached patch has been tested on x86_64-*-freebsd. PR fortran/77960 uses a procedure pointer to expose the bug, but it applied to any external subprogram. So, the patch checks for the external attribute. OK to commit? 2019-01-19 Steven G. Kargl PR fortran/77960 * io.c (match_io_element): input-item cannot be an external function. 2019-01-19 Steven G. Kargl PR fortran/77960 * gfortran.dg/pr77960.f90: New test. Index: gcc/fortran/io.c =================================================================== --- gcc/fortran/io.c (revision 268095) +++ gcc/fortran/io.c (working copy) @@ -3610,6 +3610,16 @@ match_io_element (io_kind k, gfc_code **cpp) m = gfc_match_variable (&expr, 0); if (m == MATCH_NO) gfc_error ("Expected variable in READ statement at %C"); + + if (m == MATCH_YES + && expr->expr_type == EXPR_VARIABLE + && expr->symtree->n.sym->attr.external) + { + gfc_error ("Expecting variable or io-implied-do at %L", + &expr->where); + m = MATCH_ERROR; + } + } else { Index: gcc/testsuite/gfortran.dg/pr77960.f90 =================================================================== --- gcc/testsuite/gfortran.dg/pr77960.f90 (nonexistent) +++ gcc/testsuite/gfortran.dg/pr77960.f90 (working copy) @@ -0,0 +1,16 @@ +! { dg-do compile } +! PR fortran/77960 + procedure(g), pointer :: f + f => g + read(99) f ! { dg-error "Expecting variable" } +contains + function g() result(z) + integer :: z(2) + z = 1 + end +end + +subroutine bar(x) + integer, external :: x + read(*,*) x ! { dg-error "Expecting variable" } +end subroutine