From patchwork Sat May 28 06:24:48 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tobias Burnus X-Patchwork-Id: 97770 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 A2BFFB6F8A for ; Sat, 28 May 2011 16:25:14 +1000 (EST) Received: (qmail 1525 invoked by alias); 28 May 2011 06:25:07 -0000 Received: (qmail 1494 invoked by uid 22791); 28 May 2011 06:25:06 -0000 X-SWARE-Spam-Status: No, hits=-1.7 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE, TW_PL 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; Sat, 28 May 2011 06:24:51 +0000 Received: from [192.168.178.22] (port-92-204-35-67.dynamic.qsc.de [92.204.35.67]) by mx02.qsc.de (Postfix) with ESMTP id 68F7F1DEDA; Sat, 28 May 2011 08:24:49 +0200 (CEST) Message-ID: <4DE09530.2020103@net-b.de> Date: Sat, 28 May 2011 08:24:48 +0200 From: Tobias Burnus User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; de; rv:1.9.2.14) Gecko/20110221 SUSE/3.1.8 Thunderbird/3.1.8 MIME-Version: 1.0 To: gfortran , gcc patches Subject: [Patch, Fortran] Fix type decl of coarrays 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 Thanks for Richard for debugging this! Setting TREE_TYPE in trans-decl.c is nonsense and leads to types of the form "_Complex _Complex int". The fix is rather obvious. Build and regtested on x86-64-linux. OK for the trunk? Tobias 2011-05-28 Tobias Burnus PR fortran/18918 * trans-types.c (gfc_get_nodesc_array_type): Don't mess with the type's TREE_TYPE. * trans-array.c (gfc_conv_array_ref): Use TYPE_MAIN_VARIANT. * trans.c (gfc_build_array_ref): Ditto. 2011-05-28 Tobias Burnus PR fortran/18918 * gfortran.dg/coarray_23.f90: New. diff --git a/gcc/fortran/trans-array.c b/gcc/fortran/trans-array.c index b2992f0..d83a7a9 100644 --- a/gcc/fortran/trans-array.c +++ b/gcc/fortran/trans-array.c @@ -2628,7 +2628,7 @@ gfc_conv_array_ref (gfc_se * se, gfc_array_ref * ar, gfc_symbol * sym, se->expr = build_fold_indirect_ref_loc (input_location, se->expr); /* Use the actual tree type and not the wrapped coarray. */ - se->expr = fold_convert (TREE_TYPE (TREE_TYPE (se->expr)), se->expr); + se->expr = fold_convert (TYPE_MAIN_VARIANT (TREE_TYPE (se->expr)), se->expr); return; } diff --git a/gcc/fortran/trans-types.c b/gcc/fortran/trans-types.c index 94b9a59..02a75fd 100644 --- a/gcc/fortran/trans-types.c +++ b/gcc/fortran/trans-types.c @@ -1423,10 +1423,7 @@ gfc_get_nodesc_array_type (tree etype, gfc_array_spec * as, gfc_packed packed, if (as->rank) type = make_node (ARRAY_TYPE); else - { - type = build_variant_type_copy (etype); - TREE_TYPE (type) = etype; - } + type = build_variant_type_copy (etype); GFC_ARRAY_TYPE_P (type) = 1; TYPE_LANG_SPECIFIC (type) diff --git a/gcc/fortran/trans.c b/gcc/fortran/trans.c index fcbb850..0ab4637 100644 --- a/gcc/fortran/trans.c +++ b/gcc/fortran/trans.c @@ -320,7 +320,7 @@ gfc_build_array_ref (tree base, tree offset, tree decl) { gcc_assert (GFC_TYPE_ARRAY_CORANK (type) > 0); - return fold_convert (TREE_TYPE (type), base); + return fold_convert (TYPE_MAIN_VARIANT (type), base); } gcc_assert (TREE_CODE (type) == ARRAY_TYPE); --- /dev/null 2011-05-27 20:00:22.465849134 +0200 +++ gcc/gcc/testsuite/gfortran.dg/coarray_23.f90 2011-05-28 08:03:35.000000000 +0200 @@ -0,0 +1,13 @@ +! { dg-do compile } +! { dg-options "-fcoarray=single" } +! +! PR fortran/18918 +! +! The example was ICEing before as the tree-decl +! of the type was wrong. +! + + subroutine test + complex, save :: z[*] + if (z /= cmplx (0.0, 0.0)) call abort() + end subroutine test