From patchwork Wed Jul 28 08:45:09 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tobias Burnus X-Patchwork-Id: 60126 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 EBE701007D2 for ; Wed, 28 Jul 2010 18:45:29 +1000 (EST) Received: (qmail 17711 invoked by alias); 28 Jul 2010 08:45:24 -0000 Received: (qmail 17672 invoked by uid 22791); 28 Jul 2010 08:45:22 -0000 X-SWARE-Spam-Status: No, hits=-1.9 required=5.0 tests=AWL, BAYES_00, 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 08:45:12 +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 1F8B01E453; Wed, 28 Jul 2010 10:45:10 +0200 (CEST) Message-ID: <4C4FEE15.3050108@net-b.de> Date: Wed, 28 Jul 2010 10:45:09 +0200 From: Tobias Burnus User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.10) Gecko/20100520 SUSE/3.0.5 Thunderbird/3.0.5 MIME-Version: 1.0 To: gfortran , gcc patches Subject: [Patch,Fortran,committed] PR 45077 - derived type decl 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, another case where the decl of a derived type was wrong: If the derived type was defined in a module, but not used in the module. In this case, the backend_decl of the module type is NULL. Thus, at every place where the type was used, a new backend_decl was created. The fix is obvious: Just create the backend decl. Note, however, that when the module is moved into a separate file, the test case will still fail as no suitable "gsym" exists. That's similar to the remaining issue of PR 44945 - except that there the issue is a module variable. Possibly, the same issue also exists for module procedures - though, I couldn't produce a failing test case. Build and regtested on x86-64-linux. Committed as Rev. 162619. Tobias 2010-07-28 Tobias Burnus PR fortran/45077 * trans-types.c (gfc_get_derived_type): Fix DT declaration from modules for whole-file mode. 2010-07-28 Tobias Burnus PR fortran/45077 * gfortran.dg/whole_file_24.f90: New. Index: gcc/fortran/trans-types.c =================================================================== --- gcc/fortran/trans-types.c (revision 162617) +++ gcc/fortran/trans-types.c (working copy) @@ -1994,8 +1994,10 @@ gfc_get_derived_type (gfc_symbol * deriv gfc_symbol *s; s = NULL; gfc_find_symbol (derived->name, gsym->ns, 0, &s); - if (s && s->backend_decl) + if (s) { + if (!s->backend_decl) + s->backend_decl = gfc_get_derived_type (s); gfc_copy_dt_decls_ifequal (s, derived, true); goto copy_derived_types; } Index: gcc/testsuite/gfortran.dg/whole_file_24.f90 =================================================================== --- gcc/testsuite/gfortran.dg/whole_file_24.f90 (revision 0) +++ gcc/testsuite/gfortran.dg/whole_file_24.f90 (revision 0) @@ -0,0 +1,35 @@ +! { dg-do compile } +! +! PR fortran/45077 +! +! Contributed by Dominique d'Humieres, based on a test +! case of Juergen Reuter. +! + +module iso_red + type, public :: varying_string + character(LEN=1), dimension(:), allocatable :: chars + end type varying_string +end module iso_red + +module ifiles + use iso_red, string_t => varying_string +contains + function line_get_string_advance (line) result (string) + type(string_t) :: string + character :: line + end function line_get_string_advance +end module ifiles + +module syntax_rules + use iso_red, string_t => varying_string + use ifiles, only: line_get_string_advance +contains + subroutine syntax_init_from_ifile () + type(string_t) :: string + string = line_get_string_advance ("") + end subroutine syntax_init_from_ifile +end module syntax_rules +end + +! { dg-final { cleanup-modules "iso_red ifiles syntax_rules" } }