From patchwork Sun Jan 30 17:48:00 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tobias Burnus X-Patchwork-Id: 81039 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 E28D51007D1 for ; Mon, 31 Jan 2011 04:48:11 +1100 (EST) Received: (qmail 17323 invoked by alias); 30 Jan 2011 17:48:09 -0000 Received: (qmail 17309 invoked by uid 22791); 30 Jan 2011 17:48:09 -0000 X-SWARE-Spam-Status: No, hits=-1.7 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE, TW_PG, TW_TM X-Spam-Check-By: sourceware.org Received: from mx02.qsc.de (HELO mx02.qsc.de) (213.148.130.14) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sun, 30 Jan 2011 17:48:03 +0000 Received: from [192.168.178.22] (port-92-204-33-159.dynamic.qsc.de [92.204.33.159]) by mx02.qsc.de (Postfix) with ESMTP id B28331E5FA; Sun, 30 Jan 2011 18:48:00 +0100 (CET) Message-ID: <4D45A450.9020505@net-b.de> Date: Sun, 30 Jan 2011 18:48:00 +0100 From: Tobias Burnus User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; de; 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 47042 - Reject statement functions w/ pointer attribute 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 Statement functions with pointer or allocatable attribute seem to be invalid - thus, reject them. Build and regtested on x86-64-linux. OK for the trunk? Tobias PS: gfortran, g95 and pgf95 did accept statement function with pointer attribute (cf. example in the PR) - though it is rather unclear how they could be handled. Other compilers (pathscale, NAG, ifort) reject them - and F77 did not support POINTER thus I think one can reject it unconditionally. 2011-01-31 Tobias Burnus PR fortran/47042 * resolve.c (resolve_fl_procedure): Reject stmt functions with pointer/allocatable attribute. 2011-01-31 Tobias Burnus PR fortran/47042 * gfortran.dg/stmt_func_1.f90: New. diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c index 55b5183..20be0d1 100644 --- a/gcc/fortran/resolve.c +++ b/gcc/fortran/resolve.c @@ -10231,6 +10231,14 @@ resolve_fl_procedure (gfc_symbol *sym, int mp_flag) return FAILURE; } + if (sym->attr.proc == PROC_ST_FUNCTION + && (sym->attr.allocatable || sym->attr.pointer)) + { + gfc_error ("Statement function '%s' at %L may not have pointer or " + "allocatable attribute", sym->name, &sym->declared_at); + return FAILURE; + } + /* 5.1.1.5 of the Standard: A function name declared with an asterisk char-len-param shall not be array-valued, pointer-valued, recursive or pure. ....snip... A character value of * may only be used in the --- /dev/null 2011-01-30 09:39:30.783999991 +0100 +++ gcc/gcc/testsuite/gfortran.dg/stmt_func_1.f90 2011-01-30 18:12:22.000000000 +0100 @@ -0,0 +1,12 @@ +! { dg-compile } +! { dg-options "" } +! +! PR fortran/47542 +! +integer, target, save :: tgt = 77 +integer, pointer ::ptr_stmt ! { dg-error "Statement function .ptr_stmt. at .1. may not have pointer or allocatable attribute" } +integer, allocatable :: alloc_stmt ! { dg-error "Statement function .alloc_stmt. at .1. may not have pointer or allocatable attribute" } + +ptr_stmt() = tgt +alloc_stmt() = 78 +end