From patchwork Thu Jun 6 15:10:19 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tobias Burnus X-Patchwork-Id: 249448 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 CDBDD2C0079 for ; Fri, 7 Jun 2013 01:10:37 +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=DhqwArP0jjOFkkDtz/QgIcDia3LadHRkjvcUWCsaUfy1va QqaTBeD5BR7e8giU4aIwNsCv6XzMUZUU9TzEXBZJQ1HDgZIkSpgY1kCjg8sCWZG3 d9sA02FFuDNMMRnBocwDF2BDG9HfENaKtAldFQO7ZyK7fhxlInQOAw39tfAsw= 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=T6JDEeWtqvT7nNYkuEs4a2/27/8=; b=Ms+ZOL8m/A05LfIfTthp ON30GgPrcF44f5Rnjz8FEeG559e71vsiFvLmnPQTqcyQwjItCK9kuVojw4v+EwSp OVS0hIpZGLxUJzBOCcAiAhhIYvw+VqG6NBQEBxSjXWFVrHiHPc8OYxz48lpN+lAR fvDyjtG6w1+3F11opYHT8BA= Received: (qmail 15448 invoked by alias); 6 Jun 2013 15:10:28 -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 15403 invoked by uid 89); 6 Jun 2013 15:10:28 -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 mx01.qsc.de (HELO mx01.qsc.de) (213.148.129.14) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Thu, 06 Jun 2013 15:10:27 +0000 Received: from archimedes.net-b.de (port-92-195-31-211.dynamic.qsc.de [92.195.31.211]) by mx01.qsc.de (Postfix) with ESMTP id 7E56F3D6B7; Thu, 6 Jun 2013 17:10:20 +0200 (CEST) Message-ID: <51B0A65B.8020609@net-b.de> Date: Thu, 06 Jun 2013 17:10:19 +0200 From: Tobias Burnus User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130510 Thunderbird/17.0.6 MIME-Version: 1.0 To: gcc patches , gfortran Subject: [Patch, Fortran] PR57535 - Fix class-array handling for function result variables X-Virus-Found: No The attached test case failed with an ICE for function result variables as in that case the function decl was used. Build and regtested on x86-64-gnu-linux. OK for the trunk? Other pending patches: * 4.8/4.9 regression with defined assignment: http://gcc.gnu.org/ml/fortran/2013-06/msg00047.html * Finalize nonallocatables with intent(out): http://gcc.gnu.org/ml/fortran/2013-06/msg00048.html Tobias 2013-06-06 Tobias Burnus PR fortran/57535 * trans-array.c (build_class_array_ref): Fix ICE for function result variables. 2013-06-06 Tobias Burnus PR fortran/57535 * gfortran.dg/class_array_18.f90: New. diff --git a/gcc/fortran/trans-array.c b/gcc/fortran/trans-array.c index 89f26d7..a4321cc 100644 --- a/gcc/fortran/trans-array.c +++ b/gcc/fortran/trans-array.c @@ -2991,7 +2991,13 @@ build_class_array_ref (gfc_se *se, tree base, tree index) if (ts == NULL) return false; - if (class_ref == NULL) + if (class_ref == NULL && expr->symtree->n.sym->attr.function + && expr->symtree->n.sym == expr->symtree->n.sym->result) + { + gcc_assert (expr->symtree->n.sym->backend_decl == current_function_decl); + decl = gfc_get_fake_result_decl (expr->symtree->n.sym, 0); + } + else if (class_ref == NULL) decl = expr->symtree->n.sym->backend_decl; else { --- /dev/null 2013-06-06 09:52:08.544104880 +0200 +++ gcc/gcc/testsuite/gfortran.dg/class_array_18.f90 2013-06-06 16:57:46.838820509 +0200 @@ -0,0 +1,16 @@ +! { dg-do compile } +! +! PR fortran/57535 +! +program test + implicit none + type t + integer :: ii = 55 + end type t +contains + function func2() + class(t), allocatable :: func2(:) + allocate(func2(3)) + func2%ii = [111,222,333] + end function func2 +end program test