From patchwork Mon Nov 4 19:54:42 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Richard Thomas X-Patchwork-Id: 288244 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.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 47F962C00CA for ; Tue, 5 Nov 2013 06:55:05 +1100 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:date:message-id:subject:from:to:content-type; q= dns; s=default; b=kVwGKCVtKCpdha/fulCbEDpffH1ipZD4W601ZKRx1LTgnP pf2WcCzBF8jEKFG1IqCap26+MikDLT/iJQ0lQJoe3OMyZkBc2BSUVS4hjRHgDQyI ngfSQQSnNLmxfLdtYQ93NKuupi7F/SzL+1JfvaDQiSKrFcBzARORiCkEeW0hY= 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 :mime-version:date:message-id:subject:from:to:content-type; s= default; bh=OO1SkC1gj6H69bBOQcSwt3HxI7g=; b=E0MUGOzKCFUvsckjiqWq oO4+SMiYLixE8ZebvfNWn5gXDy5nhjqKF778TtVe6yXkdhTOZaQLukgQphvTrk11 +a3C5ESDQ29bERkp1QTK4G7m6FhDTmlMQB0seaxjFlhVHhlpgIe6MaJcSqcChFGn Y/P7D1kUBKihn3lRt8Uj7YU= Received: (qmail 21041 invoked by alias); 4 Nov 2013 19:54:53 -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 21020 invoked by uid 89); 4 Nov 2013 19:54:52 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, RDNS_NONE, SPF_PASS, URIBL_BLOCKED autolearn=no version=3.3.2 X-Spam-User: qpsmtpd, 2 recipients X-HELO: mail-wi0-f180.google.com Received: from Unknown (HELO mail-wi0-f180.google.com) (209.85.212.180) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Mon, 04 Nov 2013 19:54:51 +0000 Received: by mail-wi0-f180.google.com with SMTP id ey11so1083809wid.1 for ; Mon, 04 Nov 2013 11:54:42 -0800 (PST) MIME-Version: 1.0 X-Received: by 10.180.12.198 with SMTP id a6mr13389316wic.38.1383594882253; Mon, 04 Nov 2013 11:54:42 -0800 (PST) Received: by 10.217.13.12 with HTTP; Mon, 4 Nov 2013 11:54:42 -0800 (PST) Date: Mon, 4 Nov 2013 20:54:42 +0100 Message-ID: Subject: [Patch, fortran] PR58771 - [4.7/4.8/4.9 Regression] ICE in transfer_expr, at fortran/trans-io.c:2164 From: Paul Richard Thomas To: "fortran@gcc.gnu.org" , gcc-patches Dear All, When I first posted it in Bugzilla, I thought that this patch is too kludgey by far. However, it has grown on me and I now think that it is the right thing to do. The patch is self-explanatory. Bootstrapped and regtested on FC17/x86_64 - OK for trunk and 4.7/4.8 with an appropriate delay? Cheers Paul 2013-11-04 Paul Thomas PR fortran/58771 * trans-io.c (transfer_expr): If the backend_decl for a derived type is missing, build it with gfc_typenode_for_spec. 2013-11-04 Paul Thomas PR fortran/58771 * gfortran.dg/derived_external_function_1.f90 : New test Index: gcc/fortran/trans-io.c =================================================================== *** gcc/fortran/trans-io.c (revision 204285) --- gcc/fortran/trans-io.c (working copy) *************** transfer_expr (gfc_se * se, gfc_typespec *** 2146,2151 **** --- 2146,2157 ---- expr = build_fold_indirect_ref_loc (input_location, expr); + /* Make sure that the derived type has been built. An external + function, if only referenced in an io statement requires this + check (see PR58771). */ + if (ts->u.derived->backend_decl == NULL_TREE) + tmp = gfc_typenode_for_spec (ts); + for (c = ts->u.derived->components; c; c = c->next) { field = c->backend_decl; Index: gcc/testsuite/gfortran.dg/derived_external_function_1.f90 =================================================================== *** gcc/testsuite/gfortran.dg/derived_external_function_1.f90 (revision 0) --- gcc/testsuite/gfortran.dg/derived_external_function_1.f90 (working copy) *************** *** 0 **** --- 1,27 ---- + ! { dg-do run } + ! + ! PR fortran/58771 + ! + ! Contributed by Vittorio Secca + ! + ! ICEd on the write statement with f() because the derived type backend + ! declaration not built. + ! + module m + type t + integer(4) g + end type + end + + type(t) function f() result(ff) + use m + ff%g = 42 + end + + use m + character (20) :: line1, line2 + type(t) f + write (line1, *), f() + write (line2, *), 42_4 + if (line1 .ne. line2) call abort + end