From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22224 invoked by alias); 6 Jun 2013 14:36:52 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 22207 invoked by uid 89); 6 Jun 2013 14:36:52 -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 14:36:51 +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 BD2303D572; Thu, 6 Jun 2013 16:36:48 +0200 (CEST) Message-ID: <51B09E7F.7020302@net-b.de> Date: Thu, 06 Jun 2013 14:36:00 -0000 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, committed] PR57542 - Fix regression with the final call Content-Type: multipart/mixed; boundary="------------080306020608080604060506" X-Virus-Found: No X-SW-Source: 2013-06/txt/msg00321.txt.bz2 This is a multi-part message in MIME format. --------------080306020608080604060506 Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit Content-length: 242 As the test case shows, it can happen (-fcheck=bounds) that se.pre has a value. Hence, the patch removes se.pre from the assert and adds the pre block to the block. Build, regtested and committed (Rev. 199736) on x86-64-gnu-linux. Tobias --------------080306020608080604060506 Content-Type: text/x-patch; name="final-fix.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="final-fix.diff" Content-length: 2051 2013-06-06 Tobias Burnus PR fortran/57542 * trans.c (gfc_build_final_call): Add se.pre to the block and modify the assert. 2013-06-06 Tobias Burnus PR fortran/57542 * gfortran.dg/finalize_16.f90: New. diff --git a/gcc/fortran/trans.c b/gcc/fortran/trans.c index a1ea300..dd608b7 100644 --- a/gcc/fortran/trans.c +++ b/gcc/fortran/trans.c @@ -895,7 +895,8 @@ gfc_build_final_call (gfc_typespec ts, gfc_expr *final_wrapper, gfc_expr *var, gcc_assert (class_size); gfc_init_se (&se, NULL); gfc_conv_expr (&se, class_size); - gcc_assert (se.pre.head == NULL_TREE && se.post.head == NULL_TREE); + gfc_add_block_to_block (&block, &se.pre); + gcc_assert (se.post.head == NULL_TREE); size = se.expr; array_expr = gfc_copy_expr (var); @@ -912,7 +913,8 @@ gfc_build_final_call (gfc_typespec ts, gfc_expr *final_wrapper, gfc_expr *var, { gfc_add_data_component (array_expr); gfc_conv_expr (&se, array_expr); - gcc_assert (se.pre.head == NULL_TREE && se.post.head == NULL_TREE); + gfc_add_block_to_block (&block, &se.pre); + gcc_assert (se.post.head == NULL_TREE); array = se.expr; if (TREE_CODE (array) == ADDR_EXPR && POINTER_TYPE_P (TREE_TYPE (TREE_OPERAND (array, 0)))) --- /dev/null 2013-06-06 09:52:08.544104880 +0200 +++ gcc/gcc/testsuite/gfortran.dg/finalize_16.f90 2013-06-06 16:14:13.478988916 +0200 @@ -0,0 +1,30 @@ +! { dg-do compile } +! { dg-options "-fcheck=all" } +! +! PR fortran/57542 +! +module type_mod + type inner + end type inner + + type outer + class(inner), allocatable :: item + end type outer + + type container + class(outer), allocatable :: item + end type container + + type maintype + type(container), allocatable :: v(:) + end type maintype + +end module type_mod + +subroutine testfinal(var) + use type_mod + type(maintype), intent(inout) :: var + ! A real code would obviously check + ! this is really allocated + deallocate(var%v(1)%item%item) +end subroutine testfinal --------------080306020608080604060506--