From patchwork Fri Jan 28 16:40:20 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tobias Burnus X-Patchwork-Id: 80872 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]) by ozlabs.org (Postfix) with SMTP id AB77CB7110 for ; Sat, 29 Jan 2011 03:40:42 +1100 (EST) Received: (qmail 11291 invoked by alias); 28 Jan 2011 16:40:33 -0000 Received: (qmail 11078 invoked by uid 22791); 28 Jan 2011 16:40:31 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE X-Spam-Check-By: sourceware.org Received: from mx01.qsc.de (HELO mx01.qsc.de) (213.148.129.14) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 28 Jan 2011 16:40:26 +0000 Received: from [192.168.178.22] (port-92-204-33-159.dynamic.qsc.de [92.204.33.159]) by mx01.qsc.de (Postfix) with ESMTP id 628413D07D; Fri, 28 Jan 2011 17:40:21 +0100 (CET) Message-ID: <4D42F174.2080301@net-b.de> Date: Fri, 28 Jan 2011 17:40:20 +0100 From: Tobias Burnus User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.13) Gecko/20101206 SUSE/3.1.7 Thunderbird/3.1.7 MIME-Version: 1.0 To: gfortran , gcc patches Subject: [Patch, Fortran] PR 47507 - allow PURE functions with intent-free VALUE dummies; update to gfortran.texi 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 Two simple patches: - Small update to the F2003 status in the documentation - Allow for PURE procedures dummy arguments which are merely VALUE and have no intent. Cf. F2003's C1276 The specification-part of a pure function subprogram shall specify that all its nonpointer dummy data objects have the INTENT (IN) or the VALUE attribute. C1277 The specification-part of a pure subroutine subprogram shall specify the intents of all its nonpointer dummy data objects that do not have the VALUE attribute. Build and regtested on x86-64-linux. OK for the trunk? Tobias 2011-01-28 Tobias Burnus PR fortran/47507 * resolve.c (resolve_formal_arglist): Allow arguments with VALUE attribute also without INTENT. 2011-01-28 Tobias Burnus PR fortran/47507 * gfortran.dg/pure_formal_1.f90: New. diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c index 2436283..55b5183 100644 --- a/gcc/fortran/resolve.c +++ b/gcc/fortran/resolve.c @@ -338,15 +338,17 @@ resolve_formal_arglist (gfc_symbol *proc) if (gfc_pure (proc) && !sym->attr.pointer && sym->attr.flavor != FL_PROCEDURE) { - if (proc->attr.function && sym->attr.intent != INTENT_IN) + if (proc->attr.function && sym->attr.intent != INTENT_IN + && !sym->attr.value) gfc_error ("Argument '%s' of pure function '%s' at %L must be " - "INTENT(IN)", sym->name, proc->name, + "INTENT(IN) or VALUE", sym->name, proc->name, &sym->declared_at); - if (proc->attr.subroutine && sym->attr.intent == INTENT_UNKNOWN) + if (proc->attr.subroutine && sym->attr.intent == INTENT_UNKNOWN + && !sym->attr.value) gfc_error ("Argument '%s' of pure subroutine '%s' at %L must " - "have its INTENT specified", sym->name, proc->name, - &sym->declared_at); + "have its INTENT specified or have the VALUE " + "attribute", sym->name, proc->name, &sym->declared_at); } if (proc->attr.implicit_pure && !sym->attr.pointer --- /dev/null 2011-01-28 07:54:23.859999997 +0100 +++ gcc/gcc/testsuite/gfortran.dg/pure_formal_1.f90 2011-01-28 17:03:50.000000000 +0100 @@ -0,0 +1,16 @@ +! { dg-do compile } +! +! PR fortran/47507 +! +! PURE procedures: Allow arguments w/o INTENT if they are VALUE +! + +pure function f(x) + real, VALUE :: x + real :: f + f = sin(x) +end function f + +pure subroutine sub(x) + real, VALUE :: x +end subroutine sub