From patchwork Mon Sep 20 21:27:07 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Paul Richard Thomas X-Patchwork-Id: 65255 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 366B5B70CC for ; Tue, 21 Sep 2010 07:27:27 +1000 (EST) Received: (qmail 6919 invoked by alias); 20 Sep 2010 21:27:22 -0000 Received: (qmail 6903 invoked by uid 22791); 20 Sep 2010 21:27:20 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE X-Spam-Check-By: sourceware.org Received: from mail-bw0-f47.google.com (HELO mail-bw0-f47.google.com) (209.85.214.47) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 20 Sep 2010 21:27:10 +0000 Received: by bwz2 with SMTP id 2so5377539bwz.20 for ; Mon, 20 Sep 2010 14:27:07 -0700 (PDT) MIME-Version: 1.0 Received: by 10.204.75.132 with SMTP id y4mr7171120bkj.130.1285018027527; Mon, 20 Sep 2010 14:27:07 -0700 (PDT) Received: by 10.204.81.211 with HTTP; Mon, 20 Sep 2010 14:27:07 -0700 (PDT) In-Reply-To: <201009201115.34063.mikael.morin@sfr.fr> References: <201009201115.34063.mikael.morin@sfr.fr> Date: Mon, 20 Sep 2010 23:27:07 +0200 Message-ID: Subject: Re: [Patch, fortran] PR45081 - [4.3/4.4/4.5/4.6 Regression] ICE in gfc_conv_array_initializer, at fortran/trans-array.c:4208 From: Paul Richard Thomas To: Mikael Morin Cc: fortran@gcc.gnu.org, gcc-patches 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 Dear Mikael, Thanks for the review. sted for. >> >> Bootstrapped and regtested on FC9/x86_64 - OK for trunk? > OK. > >> How far back >> to I fix the regression? > If it is a 4.3/4.4/4.5/4.6 regression, I would say fix on all branches. > But if you don't have the courage/feel it's not worth it, you can stop on 4.4 > or 4.5. > From my point of view having the fix on: >  - 4.5 is mandatory (PR has target milestone 4.5.2), >  - 4.4 is nice to have, >  - 4.3 is optional. Trunk was committed as r164448. 4.5 needed a rework of the patch; see attached. Committed as r164457. I'll do 4.3 and 4.4 tomorrow. Cheers Paul Index: gcc/fortran/simplify.c =================================================================== *** gcc/fortran/simplify.c (revision 164448) --- gcc/fortran/simplify.c (working copy) *************** is_constant_array_expr (gfc_expr *e) *** 228,234 **** return false; for (c = e->value.constructor; c; c = c->next) ! if (c->expr->expr_type != EXPR_CONSTANT) return false; return true; --- 228,235 ---- return false; for (c = e->value.constructor; c; c = c->next) ! if (c->expr->expr_type != EXPR_CONSTANT ! && c->expr->expr_type != EXPR_STRUCTURE) return false; return true; *************** gfc_simplify_pack (gfc_expr *array, gfc_ *** 4023,4028 **** --- 4024,4031 ---- if (array->ts.type == BT_CHARACTER) result->ts.u.cl = array->ts.u.cl; + else if (array->ts.type == BT_DERIVED) + result->ts.u.derived = array->ts.u.derived; return result; } *************** inc: *** 4472,4477 **** --- 4475,4485 ---- e->ts = source->ts; e->rank = rank; + if (source->ts.type == BT_CHARACTER) + e->ts.u.cl = source->ts.u.cl; + else if (source->ts.type == BT_DERIVED) + e->ts.u.derived = source->ts.u.derived; + return e; } *************** gfc_simplify_spread (gfc_expr *source, g *** 5158,5163 **** --- 5166,5173 ---- if (source->ts.type == BT_CHARACTER) result->ts.u.cl = source->ts.u.cl; + else if (source->ts.type == BT_DERIVED) + result->ts.u.derived = source->ts.u.derived; return result; } *************** gfc_simplify_transpose (gfc_expr *matrix *** 5420,5425 **** --- 5430,5437 ---- if (matrix->ts.type == BT_CHARACTER) result->ts.u.cl = matrix->ts.u.cl; + else if (matrix->ts.type == BT_DERIVED) + result->ts.u.derived = matrix->ts.u.derived; matrix_rows = mpz_get_si (matrix->shape[0]); matrix_ctor = matrix->value.constructor; *************** gfc_simplify_unpack (gfc_expr *vector, g *** 5503,5508 **** --- 5515,5522 ---- if (vector->ts.type == BT_CHARACTER) result->ts.u.cl = vector->ts.u.cl; + else if (vector->ts.type == BT_DERIVED) + result->ts.u.derived = vector->ts.u.derived; vector_ctor = vector->value.constructor; mask_ctor = mask->value.constructor; Index: gcc/testsuite/gfortran.dg/derived_array_intrinisics_1.f90 =================================================================== *** gcc/testsuite/gfortran.dg/derived_array_intrinisics_1.f90 (revision 0) --- gcc/testsuite/gfortran.dg/derived_array_intrinisics_1.f90 (revision 0) *************** *** 0 **** --- 1,30 ---- + ! { dg-do compile } + ! { dg-options "-fdump-tree-original" } + ! Test the fix for PR45081 in which derived type array valued intrinsics failed + ! to simplify, which caused an ICE in trans-array.c + ! + ! Contributed by Thorsten Ohl + ! + module m + implicit none + integer :: i + type t + integer :: i + end type t + type(t), dimension(4), parameter :: t1 = [( t(i), i = 1, 4)] + type(t), dimension(4), parameter :: t2 = [( t(i), i = 8, 11)] + type(t), dimension(2,2), parameter :: a = reshape ( t1, [ 2, 2 ] ) + type(t), dimension(2,2), parameter :: b = transpose (a) + type(t), dimension(4), parameter :: c = reshape ( b, [ 4 ] ) + type(t), dimension(2), parameter :: d = pack ( c, [.false.,.true.,.false.,.true.]) + type(t), dimension(4), parameter :: e = unpack (d, [.false.,.true.,.false.,.true.], t2) + type(t), dimension(4,2), parameter :: f = spread (e, 2, 2) + type(t), dimension(8), parameter :: g = reshape ( f, [ 8 ] ) + integer, parameter :: total = sum(g%i) + end module m + + use m + integer :: j + j = total + end + ! { dg-final { scan-tree-dump-times "j = 50" 1 "original" } }