From patchwork Wed Jul 25 21:23:52 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tobias Burnus X-Patchwork-Id: 173282 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 376A62C007E for ; Thu, 26 Jul 2012 07:24:18 +1000 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1343856259; h=Comment: DomainKey-Signature:Received:Received:Received:Received: Message-ID:Date:From:User-Agent:MIME-Version:To:Subject: References:In-Reply-To:Content-Type:Mailing-List:Precedence: List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender: Delivered-To; bh=WL/5ARAmm7pJfDkAFD7wwCFif78=; b=fSzil5KdzuN1O7R oUFJA53DdibUUf6xTjoa5KAn1PSvDZ2AckQnBaSLGBhVNABcbekxrk/QyOqVoWy3 pxEl3svOZMd2O7L4LmBl9rddX7sUJEYL17VpwvAiiy/jlq/8w4PIzCuu7wFTpEXl hD1SvKetjLWVAdam+sFqpRhFROgw= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Message-ID:Date:From:User-Agent:MIME-Version:To:Subject:References:In-Reply-To:Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=ZVlpfWsBzIlVHPCJbP7Vn/9a4VsdKnz2nnV4JZ09V+6KrfgmvfTM34kYT31iah 4mAZflnP1awTur72CXIGFZ5zNBrPcUSJ2RQWEDAev8Ag26zN9W9eGQzkenBQlC1i uBCPTRS2jtxefSo6QNnsdjOTau6m7+h22709iFTndNwdA=; Received: (qmail 9046 invoked by alias); 25 Jul 2012 21:24:11 -0000 Received: (qmail 9029 invoked by uid 22791); 25 Jul 2012 21:24:10 -0000 X-SWARE-Spam-Status: No, hits=-2.6 required=5.0 tests=AWL, BAYES_00, KHOP_THREADED, 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; Wed, 25 Jul 2012 21:23:55 +0000 Received: from [192.168.178.22] (port-92-204-86-97.dynamic.qsc.de [92.204.86.97]) by mx01.qsc.de (Postfix) with ESMTP id C88353CEEA; Wed, 25 Jul 2012 23:23:53 +0200 (CEST) Message-ID: <501063E8.3040601@net-b.de> Date: Wed, 25 Jul 2012 23:23:52 +0200 From: Tobias Burnus User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:14.0) Gecko/20120713 Thunderbird/14.0 MIME-Version: 1.0 To: gfortran , gcc patches Subject: Re: [Patch, Fortran] Fix module I/O with assumed-rank arrays References: <50105221.5060702@net-b.de> In-Reply-To: <50105221.5060702@net-b.de> 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 Tobias Burnus wrote: > The following issue was found by Alessandro. (It got triggered by a > larger test case, which is required for a larger patch by Alessandro, > which is not yet finished.) > > Accessing the "lower[-1]" is probably not the best idea … > > Build on x86-64-linux. > OK for the trunk? I attached the wrong version – the additional problem was that mio_integer expects nonnegative numbers. Build and tested on x86-64-linux. OK? Tobias 2012-07-25 Alessandro Fanfarillo Tobias Burnus * module.c (mio_array_spec): Don't read as->lower for assumed-rank arrays. diff --git a/gcc/fortran/module.c b/gcc/fortran/module.c index 51b7059..a4ff199 100644 --- a/gcc/fortran/module.c +++ b/gcc/fortran/module.c @@ -2359,9 +2359,15 @@ mio_array_spec (gfc_array_spec **asp) if (iomode == IO_OUTPUT) { + int rank; + if (*asp == NULL) goto done; as = *asp; + + /* mio_integer expects nonnegative values. */ + rank = as->rank > 0 ? as->rank : 0; + mio_integer (&rank); } else { @@ -2372,12 +2378,14 @@ mio_array_spec (gfc_array_spec **asp) } *asp = as = gfc_get_array_spec (); + mio_integer (&as->rank); } - mio_integer (&as->rank); mio_integer (&as->corank); as->type = MIO_NAME (array_type) (as->type, array_spec_types); + if (iomode == IO_INPUT && as->type == AS_ASSUMED_RANK) + as->rank = -1; if (iomode == IO_INPUT && as->corank) as->cotype = (as->type == AS_DEFERRED) ? AS_DEFERRED : AS_EXPLICIT;