From patchwork Sun Apr 28 20:02:40 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tobias Burnus X-Patchwork-Id: 240305 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]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "localhost", Issuer "www.qmailtoaster.com" (not verified)) by ozlabs.org (Postfix) with ESMTPS id 81A652C008A for ; Mon, 29 Apr 2013 06:03:21 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:subject:content-type; q= dns; s=default; b=aQ/MC05S6pfJtmPnb7p0S1+hQZyaPY9KwI43XI4NHCm91c 3b7BhL0fCFtlnRxbbgtvJDiuQDo+Iu2/jE+FPXLv9vzExxjeJvkd6cDjYJVfS6Um QmC2Cs8LtVNsmfI4qfa3uMwEUE/Myq8TIJsjv+xsY5WZ0mKQztZV8P2B1WWng= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:subject:content-type; s= default; bh=t6PkCkQcv0/bnDuWwrI5rvBlOws=; b=GdwlVVRIYNZpVDU5fcee 2WS7sQuGzgGt4f8hwfJ3MIs0oHZ8+HDtfgnskyI7x/QC2u5Nq7Hapib9MxXuNiXD FAimAHLSi+vg9yzZRU+8KQ1970cJu0b378XxlNj1fla6mZrsv3ezWg9oQAnOc4O5 g4Dz3oG3oJjqYxHfQqYcf04= Received: (qmail 8305 invoked by alias); 28 Apr 2013 20:03:15 -0000 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 Received: (qmail 8290 invoked by uid 89); 28 Apr 2013 20:03:15 -0000 X-Spam-SWARE-Status: No, score=-2.2 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 X-Spam-User: qpsmtpd, 2 recipients Received: from mx02.qsc.de (HELO mx02.qsc.de) (213.148.130.14) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Sun, 28 Apr 2013 20:02:45 +0000 Received: from archimedes.net-b.de (port-92-195-76-58.dynamic.qsc.de [92.195.76.58]) by mx02.qsc.de (Postfix) with ESMTP id 657F4276CF; Sun, 28 Apr 2013 22:02:41 +0200 (CEST) Message-ID: <517D8060.2050400@net-b.de> Date: Sun, 28 Apr 2013 22:02:40 +0200 From: Tobias Burnus User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130329 Thunderbird/17.0.5 MIME-Version: 1.0 To: gcc patches , gfortran Subject: [Patch, Fortran] PR57093 - fix to-small malloc size with scalar coarrays of type character X-Virus-Found: No The problem is a bit nested but the solution is obvious: The type (TREE_TYPE) of an array is an array type - and one needs to drill one level deeper to get the element type. For allocatable scalar coarrays, one has an array descriptor to handle the bounds (and, with -fcoarray=lib, to store the coarray token) but the type is a scalar. gfc_get_element_type by default applies TREE_TYPE twice - which is once to much for coarrays. There was a check that this is not done for arrays. Unfortunately, character strings are internally arrays as well. Thus, the second TREE_TYPE didn't give the array (with the proper string length) but an element of the string, which only had size 1 (for kind=1 characters). The solution is obvious, see patch. Committed as Rev. 198379 after bootstrapping and regtesting on x86-64-gnu-linux. Tobias Index: gcc/fortran/ChangeLog =================================================================== --- gcc/fortran/ChangeLog (Revision 198378) +++ gcc/fortran/ChangeLog (Arbeitskopie) @@ -1,3 +1,10 @@ +2013-04-28 Tobias Burnus + + PR fortran/57093 + * trans-types.c (gfc_get_element_type): Fix handling + of scalar coarrays of type character. + * intrinsic.texi (PACK): Add missing ")". + 2013-04-28 Thomas Koenig PR fortran/57071 @@ -6,9 +13,9 @@ 2013-04-25 Janne Blomqvist - PR bootstrap/57028 - * Make-lang.in (f951): Link in ZLIB. - (CFLAGS-fortran/module.o): Add zlib include directory. + PR bootstrap/57028 + * Make-lang.in (f951): Link in ZLIB. + (CFLAGS-fortran/module.o): Add zlib include directory. 2013-04-22 Janus Weil Index: gcc/fortran/intrinsic.texi =================================================================== --- gcc/fortran/intrinsic.texi (Revision 198378) +++ gcc/fortran/intrinsic.texi (Arbeitskopie) @@ -9619,7 +9619,7 @@ Fortran 95 and later Transformational function @item @emph{Syntax}: -@code{RESULT = PACK(ARRAY, MASK[,VECTOR]} +@code{RESULT = PACK(ARRAY, MASK[,VECTOR])} @item @emph{Arguments}: @multitable @columnfractions .15 .70 Index: gcc/fortran/trans-types.c =================================================================== --- gcc/fortran/trans-types.c (Revision 198378) +++ gcc/fortran/trans-types.c (Arbeitskopie) @@ -1179,7 +1179,7 @@ gfc_get_element_type (tree type) element = TREE_TYPE (element); /* For arrays, which are not scalar coarrays. */ - if (TREE_CODE (element) == ARRAY_TYPE) + if (TREE_CODE (element) == ARRAY_TYPE && !TYPE_STRING_FLAG (element)) element = TREE_TYPE (element); } Index: gcc/testsuite/ChangeLog =================================================================== --- gcc/testsuite/ChangeLog (Revision 198378) +++ gcc/testsuite/ChangeLog (Arbeitskopie) @@ -1,3 +1,8 @@ +2013-04-28 Tobias Burnus + + PR fortran/57093 + * gfortran.dg/coarray_30.f90: New. + 2013-04-28 Thomas Koenig PR fortran/57071 @@ -43,7 +48,7 @@ 2013-04-25 Marek Polacek PR tree-optimization/57066 - * gcc.dg/torture/builtin-logb-1.c: Adjust testcase. + * gcc.dg/torture/builtin-logb-1.c: Adjust testcase. 2013-04-25 James Greenhalgh Tejas Belagod Index: gcc/testsuite/gfortran.dg/coarray_30.f90 =================================================================== --- gcc/testsuite/gfortran.dg/coarray_30.f90 (Revision 0) +++ gcc/testsuite/gfortran.dg/coarray_30.f90 (Arbeitskopie) @@ -0,0 +1,15 @@ +! { dg-do compile } +! { dg-options "-fcoarray=single -fdump-tree-original" } +! +! PR fortran/57093 +! +! Contributed by Damian Rouson +! +program main + character(len=25), allocatable :: greeting[:] + allocate(greeting[*]) + write(greeting,"(a)") "z" +end + +! { dg-final { scan-tree-dump-times "greeting.data = \\(void . restrict\\) __builtin_malloc \\(25\\);" 1 "original" } } +! { dg-final { cleanup-tree-dump "original" } }