From patchwork Sat Aug 27 00:06:05 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Steve Kargl X-Patchwork-Id: 663271 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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 3sLdVz4Zdpz9sBg for ; Sat, 27 Aug 2016 10:06:32 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=VFYOeHA7; dkim-atps=neutral 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:cc:subject:message-id:reply-to:references:mime-version :content-type:content-transfer-encoding:in-reply-to; q=dns; s= default; b=fitEKUPSjX3WpGLAJOXkn4TxNI2EuqMiY1RE/3DsHpYi1nJqrzf2Q vzfinNEbQYXYEJwABxuAHXEH4RPBCeD5bLJJcORL7eX3eif+l9z71bhenMUkoMqI J4ynnfLzuOQ0iegXl92lOzi2NrgKNoTl6xksA0BXUuKNDbSMtC6j9Y= 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:cc:subject:message-id:reply-to:references:mime-version :content-type:content-transfer-encoding:in-reply-to; s=default; bh=XLLwWmM64tcRSyrSHZqg85pQ19Y=; b=VFYOeHA7pDiA31veTePwh6riAZFw oDVOquyUnYEcTFqpuEEAJ9z0liYJEeYnDTpyptUVr1YCKQTZNswCLL/FjumgPoWs 2p7vbvRbCjtkwtZj7QokxRA9OC/eZMmfSmadWlxHCQns1j7KVgM97O1mD0T8kLBU TRJHP/uA/NRdsWQ= Received: (qmail 116254 invoked by alias); 27 Aug 2016 00:06:21 -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 116234 invoked by uid 89); 27 Aug 2016 00:06:18 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=2.0 required=5.0 tests=AWL, BAYES_50, KAM_ASCII_DIVIDERS, KAM_LAZY_DOMAIN_SECURITY, RP_MATCHES_RCVD autolearn=no version=3.3.2 spammy=Morin, morin, UD:allocatable, UD:deferred X-Spam-User: qpsmtpd, 2 recipients 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, 27 Aug 2016 00:06:08 +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 u7R066Vc003615 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 26 Aug 2016 17:06:06 -0700 (PDT) (envelope-from sgk@troutmask.apl.washington.edu) Received: (from sgk@localhost) by troutmask.apl.washington.edu (8.15.2/8.15.2/Submit) id u7R065g7003614; Fri, 26 Aug 2016 17:06:05 -0700 (PDT) (envelope-from sgk) Date: Fri, 26 Aug 2016 17:06:05 -0700 From: Steve Kargl To: Mikael Morin Cc: fortran@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: Re: [PATCH(es)] PR fortran/77391 -- RFC vote on which you prefer Message-ID: <20160827000605.GA3601@troutmask.apl.washington.edu> Reply-To: kargl@uw.edu References: <20160826182755.GA63696@troutmask.apl.washington.edu> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.6.1 (2016-04-27) On Fri, Aug 26, 2016 at 10:28:25PM +0200, Mikael Morin wrote: > Hello, > > Le 26/08/2016 à 20:27, Steve Kargl a écrit : > > Here are two possible patches for PR fortran/77391. The first > > patch treats the invalid code as a GNU Fortran extension as > > gfortran current accepts the invalid code. The second patch > > enforces the standard. As I think gfortran should encourage > > standard conformance, I am inclined to commit the second patch. > > I will however commit the most popular of the two patches tomorrow. > > Voting starts now and will remain open for 24 hours (give or take > > a few hours depend on when I awaken). > > > > I don't think it's sufficient to check current_attr because of this case: > > character(:) :: a > pointer :: a > end > > The statement should be accepted, and the check be postponed at a time > after the symbol has been initialised, at resolution time for example. > So, I've come up the following. We now need to debate whether Dominiq's observations mean that C402 does not apply to named constant. 2016-08-26 Steven G. Kargl PR fortran/77391 * resolve.c (deferred_requirements): New function to check F2008:C402. (resolve_fl_variable,resolve_fl_parameter): Use it. 2016-08-26 Steven G. Kargl PR fortran/77391 * gfortran.dg/pr77391.f90: New test. Index: gcc/fortran/resolve.c =================================================================== --- gcc/fortran/resolve.c (revision 239762) +++ gcc/fortran/resolve.c (working copy) @@ -11402,6 +11402,27 @@ resolve_fl_variable_derived (gfc_symbol } +/* F2008, C402 (R401): A colon shall not be used as a type-param-value + except in the declaration of an entity or component that has the POINTER + or ALLOCATABLE attribute. */ + +static bool +deferred_requirements (gfc_symbol *sym) +{ + if (sym->ts.deferred + && !(sym->attr.pointer + || sym->attr.allocatable + || sym->attr.omp_udr_artificial_var)) + { + gfc_error ("Entity %qs at %L has a deferred type parameter and " + "requires either the POINTER or ALLOCATABLE attribute", + sym->name, &sym->declared_at); + return false; + } + return true; +} + + /* Resolve symbols with flavor variable. */ static bool @@ -11441,17 +11462,8 @@ resolve_fl_variable (gfc_symbol *sym, in } /* Constraints on deferred type parameter. */ - if (sym->ts.deferred - && !(sym->attr.pointer - || sym->attr.allocatable - || sym->attr.omp_udr_artificial_var)) - { - gfc_error ("Entity %qs at %L has a deferred type parameter and " - "requires either the pointer or allocatable attribute", - sym->name, &sym->declared_at); - specification_expr = saved_specification_expr; - return false; - } + if (!deferred_requirements (sym)) + return false; if (sym->ts.type == BT_CHARACTER) { @@ -13570,6 +13582,10 @@ resolve_fl_parameter (gfc_symbol *sym) return false; } + /* Constraints on deferred type parameter. */ + if (!deferred_requirements (sym)) + return false; + /* Make sure a parameter that has been implicitly typed still matches the implicit type, since PARAMETER statements can precede IMPLICIT statements. */ Index: gcc/testsuite/gfortran.dg/pr77391.f90 =================================================================== --- gcc/testsuite/gfortran.dg/pr77391.f90 (nonexistent) +++ gcc/testsuite/gfortran.dg/pr77391.f90 (working copy) @@ -0,0 +1,7 @@ +! { dg-do compile } +program picky +character(len=:), parameter :: a="whoops" ! { dg-error "POINTER or ALLOCATABLE" } +character(len=:) :: b="whoops" ! { dg-error "POINTER or ALLOCATABLE" } +character(len=:) :: good +pointer good +end program picky