From patchwork Mon Jun 3 14:06:03 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tobias Burnus X-Patchwork-Id: 248289 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 542322C00A4 for ; Tue, 4 Jun 2013 00:06:25 +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=mNg2IRKdWFQLVmwgzilv9bMaO/9ZKUi+MR/gNMLmg833r0 ou/SxVAckvzViSnGDo0y4CIGm7Qbc2K3ljXQ+Vht1AV5dXVza/E5hhd65Mjbr4Jo +VGnKs5j96BGZoVbz4H0N517SEScgiRTj9Oht5ybe87awnTIC1FKrw+1UeBJE= 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=u7thp8CoE9iwmCGl/EYmifQ3jN4=; b=jRAiY0KYHZzwRHAB0Gcc xHzvXO4i5SdVOe8AFLnkB9nOrl09gLt2+incSnHOWa9mMQOp8xlM0hEn+NO9geLL 9gRNe7vOxvdomniK9I0wErT1y48KY2gwSy+OwfMG0896c8nhARD6SKVQPDMeqKY/ 47F+QCuwIbYsbd46N+IhU8w= Received: (qmail 8717 invoked by alias); 3 Jun 2013 14:06:14 -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 8691 invoked by uid 89); 3 Jun 2013 14:06:13 -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, 3 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; Mon, 03 Jun 2013 14:06:08 +0000 Received: from archimedes.net-b.de (port-92-195-106-97.dynamic.qsc.de [92.195.106.97]) by mx01.qsc.de (Postfix) with ESMTP id 6CC913CE91; Mon, 3 Jun 2013 16:06:04 +0200 (CEST) Message-ID: <51ACA2CB.6010601@net-b.de> Date: Mon, 03 Jun 2013 16:06:03 +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 , Janus Weil Subject: [Patch, Fortran] PR57508 - Fix ICE/Reject-valid issue with get_temp_from_expr (intrinsic assignment with defined assignment) X-Virus-Found: No Dear all, Due to copying the attributes, the temporary variable could get marked as function (attr.function, attr.flavor == FL_PROCEDURE). This either lead to leaking those attributes into the assembler file - or to cause an error due to the call to gfc_add_flavor. With this patch, I now explicitly unset those attribues. (Fund when building ForTrilinos.) Build and OK for the trunk and GCC 4.8? Tobias 2013-06-03 Tobias Burnus PR fortran/57508 * resolve.c (get_temp_from_expr): Don't copy function result attributes to temporary. 2013-06-03 Tobias Burnus PR fortran/57508 * gfortran.dg/defined_assignment_7.f90: New. diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c index b2e8fdc..655d3c1 100644 --- a/gcc/fortran/resolve.c +++ b/gcc/fortran/resolve.c @@ -9293,8 +9293,12 @@ get_temp_from_expr (gfc_expr *e, gfc_namespace *ns) } } /* Add the attributes and the arrayspec to the temporary. */ /* Add the attributes and the arrayspec to the temporary. */ tmp->n.sym->attr = gfc_expr_attr (e); + tmp->n.sym->attr.function = 0; + tmp->n.sym->attr.result = 0; + tmp->n.sym->attr.flavor = FL_VARIABLE; + if (as) { tmp->n.sym->as = gfc_copy_array_spec (as); @@ -9307,7 +9311,6 @@ get_temp_from_expr (gfc_expr *e, gfc_namespace *ns) tmp->n.sym->attr.dimension = 0; gfc_set_sym_referenced (tmp->n.sym); - gfc_add_flavor (&tmp->n.sym->attr, FL_VARIABLE, name, NULL); gfc_commit_symbol (tmp->n.sym); e = gfc_lval_expr_from_sym (tmp->n.sym); --- /dev/null 2013-06-03 08:35:13.011105509 +0200 +++ gcc/gcc/testsuite/gfortran.dg/defined_assignment_7.f90 2013-06-03 15:58:17.227408173 +0200 @@ -0,0 +1,29 @@ +! { dg-compile } +! +! PR fortran/57508 +! +module ForTrilinos_ref_counter + type ref_counter + contains + procedure :: assign + generic :: assignment(=) => assign + end type +contains + subroutine assign (lhs, rhs) + class (ref_counter), intent(inout) :: lhs + class (ref_counter), intent(in) :: rhs + end subroutine +end module +module FEpetra_BlockMap + use ForTrilinos_ref_counter, only : ref_counter + type :: Epetra_BlockMap + type(ref_counter) :: counter + end type +contains + function from_struct() result(new_Epetra_BlockMap) + type(Epetra_BlockMap) :: new_Epetra_BlockMap + end function + type(Epetra_BlockMap) function create_arbitrary() + create_arbitrary = from_struct() + end function +end module