From patchwork Mon May 30 15:26:45 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tobias Burnus X-Patchwork-Id: 97930 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 3446FB6EE9 for ; Tue, 31 May 2011 01:27:08 +1000 (EST) Received: (qmail 30824 invoked by alias); 30 May 2011 15:27:04 -0000 Received: (qmail 30800 invoked by uid 22791); 30 May 2011 15:27:02 -0000 X-SWARE-Spam-Status: No, hits=-0.8 required=5.0 tests=AWL, BAYES_40, 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; Mon, 30 May 2011 15:26:47 +0000 Received: from [192.168.178.22] (port-92-204-18-93.dynamic.qsc.de [92.204.18.93]) by mx02.qsc.de (Postfix) with ESMTP id 578241E3C7; Mon, 30 May 2011 17:26:46 +0200 (CEST) Message-ID: <4DE3B735.3070904@net-b.de> Date: Mon, 30 May 2011 17:26:45 +0200 From: Tobias Burnus User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.14) Gecko/20110221 SUSE/3.1.8 Thunderbird/3.1.8 MIME-Version: 1.0 To: gcc patches , gfortran Subject: [Patch, Fortran] Coarray - fix assumed-shape cobounds 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 Simple patch, which requires the previous patch at http://gcc.gnu.org/ml/fortran/2011-05/msg00231.html OK for the trunk? Tobias 2011-05-30 Tobias Burnus PR fortran/18918 * trans-array.c (gfc_trans_dummy_array_bias): Handle cobounds of assumed-shape arrays. 2011-05-30 Tobias Burnus PR fortran/18918 * gfortran.dg/coarray/dummy_1.f90: New. diff --git a/gcc/fortran/trans-array.c b/gcc/fortran/trans-array.c index d83a7a9..c7aeadb 100644 --- a/gcc/fortran/trans-array.c +++ b/gcc/fortran/trans-array.c @@ -5213,6 +5232,8 @@ gfc_trans_dummy_array_bias (gfc_symbol * sym, tree tmpdesc, } } + gfc_trans_array_cobounds (type, &init, sym); + /* Set the offset. */ if (TREE_CODE (GFC_TYPE_ARRAY_OFFSET (type)) == VAR_DECL) gfc_add_modify (&init, GFC_TYPE_ARRAY_OFFSET (type), offset); --- /dev/null 2011-05-29 07:20:52.091892040 +0200 +++ gcc/gcc/testsuite/gfortran.dg/coarray/dummy_1.f90 2011-05-30 17:21:53.000000000 +0200 @@ -0,0 +1,70 @@ +! { dg-do run } +! +! PR fortran/18918 +! +! Check whether assumed-shape's cobounds are properly handled +! + implicit none + integer :: B(1)[*] + integer :: C(8:11)[-3:10,43:*] + integer, allocatable :: D(:)[:,:] + + allocate (D(20)[2:3,5:*]) + + call sub (B,5) + call sub (C,3) + call sub (D,3) + + call sub2 (B, -3) + call sub2 (C, 44) + call sub2 (D, 44) + + call sub3 (B) + call sub3 (C) + call sub3 (D) + + call sub4 (B) + call sub4 (C) + call sub4 (D) + + call sub5 (D) + contains + + subroutine sub(A,n) + integer :: n + integer :: A(n:)[n:2*n,3*n:*] + if (lbound(A,dim=1) /= n) call abort () + if (any (lcobound(A) /= [n, 3*n])) call abort () + if (ucobound(A, dim=1) /= 2*n) call abort() + end subroutine sub + + subroutine sub2(A,n) + integer :: n + integer :: A(:)[-n:*] + if (lbound(A,dim=1) /= 1) call abort () + if (lcobound(A, dim=1) /= -n) call abort () + end subroutine sub2 + + subroutine sub3(A) + integer :: A(:)[0,*] + if (lbound(A,dim=1) /= 1) call abort () + if (lcobound(A, dim=1) /= 1) call abort () + if (ucobound(A, dim=1) /= 0) call abort () + if (lcobound(A, dim=2) /= 1) call abort () + end subroutine sub3 + + subroutine sub4(A) + integer :: A(:)[*] + if (lbound(A,dim=1) /= 1) call abort () + if (lcobound(A, dim=1) /= 1) call abort () + end subroutine sub4 + + subroutine sub5(A) + integer, allocatable :: A(:)[:,:] + + if (lbound(A,dim=1) /= 1) call abort () + if (lcobound(A, dim=1) /= 2) call abort () + if (ucobound(A, dim=1) /= 3) call abort () + if (lcobound(A, dim=2) /= 5) call abort () + end subroutine sub5 + end