From patchwork Fri Jul 22 21:51:31 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tobias Burnus X-Patchwork-Id: 106394 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 87438B6F64 for ; Sat, 23 Jul 2011 07:51:50 +1000 (EST) Received: (qmail 23914 invoked by alias); 22 Jul 2011 21:51:47 -0000 Received: (qmail 23898 invoked by uid 22791); 22 Jul 2011 21:51:46 -0000 X-SWARE-Spam-Status: No, hits=1.0 required=5.0 tests=AWL, BAYES_00, KAM_STOCKTIP, RCVD_IN_DNSWL_NONE 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; Fri, 22 Jul 2011 21:51:32 +0000 Received: from [192.168.178.22] (port-92-204-19-234.dynamic.qsc.de [92.204.19.234]) by mx02.qsc.de (Postfix) with ESMTP id 4647B1E217; Fri, 22 Jul 2011 23:51:31 +0200 (CEST) Message-ID: <4E29F0E3.6050002@net-b.de> Date: Fri, 22 Jul 2011 23:51:31 +0200 From: Tobias Burnus User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:5.0) Gecko/20110624 Thunderbird/5.0 MIME-Version: 1.0 To: gcc patches , gfortran Subject: [Patch, Fortran] Coarray - fix var decl check 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 Local, nostatic/nonallocable DT variables were rejected if they contained (allocatable) coarray components. However, those are allowed - I had initially misread the constraint. C526 A coarray or an object with a coarray ultimate component shall be a dummy argument or have the ALLOCATABLE or SAVE attribute. Cf. also http://j3-fortran.org/pipermail/j3/2011-June/004403.html if you have the same trouble as I initially had with "ultimate component". Build and regtested on x86-64-linux. OK for the trunk? Tobias 2011-07-23 Tobias Burnus * resolve.c (resolve_symbol): Fix coarray var decl check. 2011-07-23 Tobias Burnus * gfortran.dg/coarray_25.f90: New. diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c index 71e0ba0..e9e7bf0 100644 --- a/gcc/fortran/resolve.c +++ b/gcc/fortran/resolve.c @@ -12435,16 +12435,14 @@ resolve_symbol (gfc_symbol *sym) sym->name, &sym->declared_at); /* F2008, C526. The function-result case was handled above. */ - if (((sym->ts.type == BT_DERIVED && sym->ts.u.derived->attr.coarray_comp) - || sym->attr.codimension) + if (sym->attr.codimension && !(sym->attr.allocatable || sym->attr.dummy || sym->attr.save || sym->ns->save_all || sym->ns->proc_name->attr.flavor == FL_MODULE || sym->ns->proc_name->attr.is_main_program || sym->attr.function || sym->attr.result || sym->attr.use_assoc)) - gfc_error ("Variable '%s' at %L is a coarray or has a coarray " - "component and is not ALLOCATABLE, SAVE nor a " - "dummy argument", sym->name, &sym->declared_at); + gfc_error ("Variable '%s' at %L is a coarray and is not ALLOCATABLE, SAVE " + "nor a dummy argument", sym->name, &sym->declared_at); /* F2008, C528. */ /* FIXME: sym->as check due to PR 43412. */ else if (sym->attr.codimension && !sym->attr.allocatable && sym->as && sym->as->cotype == AS_DEFERRED) diff --git a/gcc/testsuite/gfortran.dg/coarray_4.f90 b/gcc/testsuite/gfortran.dg/coarray_4.f90 index be2bc4e..cdc4ef8 100644 --- a/gcc/testsuite/gfortran.dg/coarray_4.f90 +++ b/gcc/testsuite/gfortran.dg/coarray_4.f90 @@ -31,7 +31,7 @@ subroutine valid2() integer, allocatable :: b[:] end type tt type(tt), save :: foo - type(tt) :: bar ! { dg-error "is a coarray or has a coarray component" } + type(tt) :: bar end subroutine valid2 subroutine invalid(n) --- /dev/null 2011-07-22 07:25:31.139891427 +0200 +++ gcc/gcc/testsuite/gfortran.dg/coarray_25.f90 2011-07-22 23:10:41.000000000 +0200 @@ -0,0 +1,18 @@ +! { dg-do compile } +! { dg-options "-fcoarray=single" } +! +! Used to be rejected with: +! Error: Variable 'x' at (1) is a coarray or has a coarray +! component and is not ALLOCATABLE, SAVE nor a dummy argument +! +! Is valid as "a" is allocatable, cf. C526 +! and http://j3-fortran.org/pipermail/j3/2011-June/004403.html +! + + subroutine test2() + type t + integer, allocatable :: a(:)[:] + end type t + type(t) :: x + allocate(x%a(1)[*]) + end subroutine test2