From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18404 invoked by alias); 22 Jul 2010 13:59:57 -0000 Received: (qmail 18369 invoked by uid 22791); 22 Jul 2010 13:59:55 -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; Thu, 22 Jul 2010 13:59:49 +0000 Received: from [192.168.178.22] (port-92-204-52-63.dynamic.qsc.de [92.204.52.63]) by mx02.qsc.de (Postfix) with ESMTP id 0CC4A1E5E7; Thu, 22 Jul 2010 15:59:45 +0200 (CEST) Message-ID: <4C484ED1.2080708@net-b.de> Date: Thu, 22 Jul 2010 13:59:00 -0000 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: Paul Richard Thomas CC: gcc patches , gfortran Subject: Re: [Patch,Fortran] PR 44945 - Fix DECL of module variables (wrong-code "regression") References: <4C4066F9.80902@net-b.de> In-Reply-To: Content-Type: multipart/mixed; boundary="------------060607030501050503070205" 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 X-SW-Source: 2010-07/txt/msg01741.txt.bz2 This is a multi-part message in MIME format. --------------060607030501050503070205 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-length: 1266 Dear all, I have updated the patch. On 07/16/2010 04:40 PM, Paul Richard Thomas wrote: > On Fri, Jul 16, 2010 at 4:04 PM, Tobias Burnus wrote: > >> gfortran can produce the multiple declarations for module variables. >> This causes problems when inlining is done as then the alias analysis >> breaks. >> > OK for trunk and 4.5 after a delay of a week or two. > As written in the PR: The patch has caused ICEs with -fwhole-file for some derived types as the backend decl of the components was not copied. This is fixed by the attached patch. Additionally, I removed the -O3 from the dg-options as suggested by Jakub. Build and regtested with -fwhole-file enabled by default. (Without the code path is not taken.) I do not see any ICEs in the test suite, found one bug relating -fwhole-file and ENTRY (PR 45030), and several failures due to do changed error/warning messages. OK for the trunk - and, as suggested, for the 4.5 branch? Regarding enabling -fwhole-file by default: I think one should do so as soon as the ENTRY bug (PR 45030) is fixed. That gives us a long time during 4.5 to fix the fall out bugs. (The next step is then to fix the decl bugs, which cause -fwhole-program failues, but that's a separate issue.) Tobias --------------060607030501050503070205 Content-Type: text/x-patch; name="decl2.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="decl2.diff" Content-length: 4241 2010-07-22 Tobias Burnus PR fortran/44945 * trans-decl.c (gfc_get_symbol_decl): Use module decl with -fwhole-file also for derived types. * trans-types.c (copy_dt_decls_ifequal): Remove static and rename to gfc_copy_dt_decls_ifequal. (gfc_get_derived_type): Update call. * trans-types.h (gfc_copy_dt_decls_ifequal): Add prototype. 2010-07-22 Tobias Burnus PR fortran/44945 * gfortran.dg/char_array_structure_constructor.f90: Add -fwhole-file as dg-option as it otherwise fails on some systems. Index: gcc/fortran/trans-types.c =================================================================== --- gcc/fortran/trans-types.c (revision 162410) +++ gcc/fortran/trans-types.c (working copy) @@ -1882,8 +1882,8 @@ gfc_add_field_to_struct (tree context, t the two derived type symbols are "equal", as described in 4.4.2 and resolved by gfc_compare_derived_types. */ -static int -copy_dt_decls_ifequal (gfc_symbol *from, gfc_symbol *to, +int +gfc_copy_dt_decls_ifequal (gfc_symbol *from, gfc_symbol *to, bool from_gsym) { gfc_component *to_cm; @@ -1994,7 +1994,7 @@ gfc_get_derived_type (gfc_symbol * deriv gfc_find_symbol (derived->name, gsym->ns, 0, &s); if (s && s->backend_decl) { - copy_dt_decls_ifequal (s, derived, true); + gfc_copy_dt_decls_ifequal (s, derived, true); goto copy_derived_types; } } @@ -2014,7 +2014,7 @@ gfc_get_derived_type (gfc_symbol * deriv dt = ns->derived_types; for (; dt && !canonical; dt = dt->next) { - copy_dt_decls_ifequal (dt->derived, derived, true); + gfc_copy_dt_decls_ifequal (dt->derived, derived, true); if (derived->backend_decl) got_canonical = true; } @@ -2181,7 +2181,7 @@ gfc_get_derived_type (gfc_symbol * deriv copy_derived_types: for (dt = gfc_derived_types; dt; dt = dt->next) - copy_dt_decls_ifequal (derived, dt->derived, false); + gfc_copy_dt_decls_ifequal (derived, dt->derived, false); return derived->backend_decl; } Index: gcc/fortran/trans-types.h =================================================================== --- gcc/fortran/trans-types.h (revision 162410) +++ gcc/fortran/trans-types.h (working copy) @@ -64,6 +64,7 @@ tree gfc_get_character_type_len_for_elty tree gfc_sym_type (gfc_symbol *); tree gfc_typenode_for_spec (gfc_typespec *); +int gfc_copy_dt_decls_ifequal (gfc_symbol *, gfc_symbol *, bool); tree gfc_get_function_type (gfc_symbol *); Index: gcc/fortran/trans-decl.c =================================================================== --- gcc/fortran/trans-decl.c (revision 162410) +++ gcc/fortran/trans-decl.c (working copy) @@ -1128,11 +1128,9 @@ gfc_get_symbol_decl (gfc_symbol * sym) return sym->backend_decl; /* If use associated and whole file compilation, use the module - declaration. This is only needed for intrinsic types because - they are substituted for one another during optimization. */ + declaration. */ if (gfc_option.flag_whole_file && sym->attr.flavor == FL_VARIABLE - && sym->ts.type != BT_DERIVED && sym->attr.use_assoc && sym->module) { @@ -1146,6 +1144,9 @@ gfc_get_symbol_decl (gfc_symbol * sym) gfc_find_symbol (sym->name, gsym->ns, 0, &s); if (s && s->backend_decl) { + if (sym->ts.type == BT_DERIVED) + gfc_copy_dt_decls_ifequal (s->ts.u.derived, sym->ts.u.derived, + true); if (sym->ts.type == BT_CHARACTER) sym->ts.u.cl->backend_decl = s->ts.u.cl->backend_decl; return s->backend_decl; Index: gcc/testsuite/gfortran.dg/char_array_structure_constructor.f90 =================================================================== --- gcc/testsuite/gfortran.dg/char_array_structure_constructor.f90 (revision 162410) +++ gcc/testsuite/gfortran.dg/char_array_structure_constructor.f90 (working copy) @@ -1,4 +1,9 @@ ! { dg-do run } +! { dg-options "-fwhole-file" } +! +! PR fortran/19107 +! -fwhole-file flag added for PR fortran/44945 +! ! This test the fix of PR19107, where character array actual ! arguments in derived type constructors caused an ICE. ! It also checks that the scalar counterparts are OK. --------------060607030501050503070205--