From patchwork Wed Jul 28 20:15:00 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tobias Burnus X-Patchwork-Id: 60174 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 E59D4B6F11 for ; Thu, 29 Jul 2010 06:15:36 +1000 (EST) Received: (qmail 21559 invoked by alias); 28 Jul 2010 20:15:27 -0000 Received: (qmail 21265 invoked by uid 22791); 28 Jul 2010 20:15:12 -0000 X-SWARE-Spam-Status: No, hits=-1.2 required=5.0 tests=AWL, BAYES_00, KAM_STOCKGEN, RCVD_IN_DNSWL_NONE X-Spam-Check-By: sourceware.org Received: from mx02.qsc.de (HELO mx02.qsc.de) (213.148.130.14) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 28 Jul 2010 20:15:06 +0000 Received: from [192.168.178.22] (port-92-204-39-15.dynamic.qsc.de [92.204.39.15]) by mx02.qsc.de (Postfix) with ESMTP id A06A01E8F1; Wed, 28 Jul 2010 22:15:00 +0200 (CEST) Message-ID: <4C508FC4.1060506@net-b.de> Date: Wed, 28 Jul 2010 22:15:00 +0200 From: Tobias Burnus User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; de; rv:1.9.1.10) Gecko/20100520 SUSE/3.0.5 Thunderbird/3.0.5 MIME-Version: 1.0 To: gcc patches , gfortran Subject: [Patch,Fortran] PR 45087 - another -fwhole-program fix 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 all, here is another whole-file fix. The only remaining issues I know of are of the type MODULE in one file, several procedures using the modules in another file. In that case, no gsym is generated and one gets multiple declarations for module variables and types; I think module procedures and external procedures declared in the module (but which are not in the second file) are also affected. Cf. PR 44945 and PR 45077. This patch fixes the case that an external procedure is declared in a module - but is present in the file. In this case the declaration of the actual external procedure should be used. Built and regtested on x86-64-linux. OK for the trunk? Tobias 2010-07-28 Tobias Burnus PR fortran/45087 * trans-decl.c (gfc_get_extern_function_decl): Correctly handle external procedure declarations in modules. 2010-07-28 Tobias Burnus PR fortran/45087 * gfortran.dg/whole_file_25.f90: New. * gfortran.dg/whole_file_26.f90: New. Index: gcc/fortran/trans-decl.c =================================================================== --- gcc/fortran/trans-decl.c (Revision 162653) +++ gcc/fortran/trans-decl.c (Arbeitskopie) @@ -1409,7 +1409,7 @@ gfc_get_extern_function_decl (gfc_symbol gsym = gfc_find_gsymbol (gfc_gsym_root, sym->name); if (gfc_option.flag_whole_file - && !sym->attr.use_assoc + && (!sym->attr.use_assoc || sym->attr.if_source != IFSRC_DECL) && !sym->backend_decl && gsym && gsym->ns && ((gsym->type == GSYM_SUBROUTINE) || (gsym->type == GSYM_FUNCTION)) @@ -1450,12 +1450,17 @@ gfc_get_extern_function_decl (gfc_symbol } } else - { - sym->backend_decl = gsym->ns->proc_name->backend_decl; - } + sym->backend_decl = gsym->ns->proc_name->backend_decl; if (sym->backend_decl) - return sym->backend_decl; + { + /* Avoid problems of double deallocation of the backend declaration + later in gfc_trans_use_stmts; cf. PR 45087. */ + if (sym->attr.if_source != IFSRC_DECL && sym->attr.use_assoc) + sym->attr.use_assoc = 0; + + return sym->backend_decl; + } } /* See if this is a module procedure from the same file. If so, Index: gcc/testsuite/gfortran.dg/whole_file_26.f90 =================================================================== --- gcc/testsuite/gfortran.dg/whole_file_26.f90 (Revision 0) +++ gcc/testsuite/gfortran.dg/whole_file_26.f90 (Revision 0) @@ -0,0 +1,26 @@ +! { dg-do compile } +! { dg-options "-fwhole-program --param ggc-min-expand=0 --param ggc-min-heapsize=0" } +! +! PR fortran/45087 +! + +module INTS + interface + subroutine NEXT + end subroutine NEXT + subroutine VALUE() + end subroutine VALUE + end interface +end module INTS + +subroutine NEXT +end subroutine NEXT + +subroutine VALUE() + use INTS, only: NEXT + CALL NEXT +end subroutine VALUE + +end + +! { dg-final { cleanup-modules "ints" } } Index: gcc/testsuite/gfortran.dg/whole_file_25.f90 =================================================================== --- gcc/testsuite/gfortran.dg/whole_file_25.f90 (Revision 0) +++ gcc/testsuite/gfortran.dg/whole_file_25.f90 (Revision 0) @@ -0,0 +1,21 @@ +! { dg-do compile } +! { dg-options "-fwhole-program" } +! +! PR fortran/45087 +! + +module ints + INTERFACE + SUBROUTINE NOZZLE() + END SUBROUTINE NOZZLE + END INTERFACE +end module ints + + SUBROUTINE NOZZLE() + END SUBROUTINE NOZZLE + program CORTESA + USE INTS + CALL NOZZLE () + END program CORTESA + +! { dg-final { cleanup-modules "ints" } }