From patchwork Sun Feb 3 21:34:50 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mikael Morin X-Patchwork-Id: 217809 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 AF1A52C008E for ; Mon, 4 Feb 2013 08:35:25 +1100 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1360532126; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Message-ID:Date:From:User-Agent:MIME-Version:To:Subject: Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:Sender:Delivered-To; bh=6CsxdYR vpakQeeUqLqnjeh6NxPU=; b=ZYSHKTxeCU5MbUfkTO6C+PgEFbKa4LsiUFI1vLt drPCocxWFzwNpbnJK9ILwkwKWEacS8FNlcgUIhZ6fr7rfb2FAVcyGI0sRULQiA0f 9IGa9+YE61fhZPnFMmVBKRpBa4zJlGsK0uQD8nZRonK+ZOKqKyiL+HgfM1/WDiid p1Bc= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Received:X-SFR-UUID:Message-ID:Date:From:User-Agent:MIME-Version:To:Subject:Content-Type:X-IsSubscribed:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=Ts916f7hwllBzidi14T45bcJ4sJ5l++sN1V5UaRcj0r2uIntN3c7uWa/OHWSXh MBnh6u+99ou5Km8psBqvwQF/H2bU1I9hqlH4rH8C/IarMwOgRaNFqV94dcQkHtCD 4meNtc6voWdf1dg7rkjXZFd7V1E3b41De733ZQT0zHTSs=; Received: (qmail 5131 invoked by alias); 3 Feb 2013 21:35:11 -0000 Received: (qmail 5041 invoked by uid 22791); 3 Feb 2013 21:35:10 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE, RCVD_IN_HOSTKARMA_NO, RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from smtp21.services.sfr.fr (HELO smtp21.services.sfr.fr) (93.17.128.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sun, 03 Feb 2013 21:35:03 +0000 Received: from filter.sfr.fr (localhost [127.0.0.1]) by msfrf2119.sfr.fr (SMTP Server) with ESMTP id 1D48A700007D; Sun, 3 Feb 2013 22:35:02 +0100 (CET) Received: from [192.168.1.58] (50.183.72.86.rev.sfr.net [86.72.183.50]) by msfrf2119.sfr.fr (SMTP Server) with ESMTP id AAEBD70000B7; Sun, 3 Feb 2013 22:35:01 +0100 (CET) X-SFR-UUID: 20130203213501700.AAEBD70000B7@msfrf2119.sfr.fr Message-ID: <510ED7FA.2050900@sfr.fr> Date: Sun, 03 Feb 2013 22:34:50 +0100 From: Mikael Morin User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130127 Thunderbird/17.0.2 MIME-Version: 1.0 To: gfortran , gcc-patches Subject: [Patch, fortran] PR54107: ICE on recursive interfaces and PR54195: symbol bogusly inserted twice in the interface. X-IsSubscribed: yes 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 Hello, The following patches fix both PR54107 and PR54195. - In PR54107(comment 26), the procedure result is a procedure pointer whose interface is the procedure itself, which leads to an infinite recursion during resolution. - In PR54195, a type's type bound procedures are resolved twice, leading to a symbol being added twice in an interface and rejected. The fix, as discussed in PR54195, adds a flag to mark a symbol as resolved. This leads to two regressions. For class_20, a check to skip result symbols had to be removed (which was there to avoid duplicated resolution). For initialization_27 (among a few others) the code adding the default initialization code was guarded by a check against gfc_current_ns, which always ended triggering when there was more than one resolution but may not anymore. The fix removes it; I checked that gfc_current_ns wasn't used in the following code. The second fix makes the recursion through resolve_symbol, so that the flag just added triggers and PR54195 is fixed. Regression tested on x86_64-unknown-linux-gnu. OK for trunk? Mikael 2013-02-03 Mikael Morin PR fortran/54107 PR fortran/54195 * gfortran.h (struct symbol_attribute): New field 'resolved'. * resolve.c (resolve_fl_var_and_proc): Don't skip result symbols. (resolve_symbol): Skip duplicate calls. Don' check the current namespace. 2013-02-03 Mikael Morin PR fortran/54107 * gfortran.dg/recursive_interface_1.f90: New test. 2013-02-03 Mikael Morin PR fortran/54195 * resolve.c (resolve_typebound_procedures): Recurse through resolve_symbol. 2013-02-03 Mikael Morin PR fortran/54195 * gfortran.dg/defined_assignment_4.f90: New test. * gfortran.dg/defined_assignment_5.f90: New test. diff --git a/resolve.c b/resolve.c index 3b74c6f..6bec662 100644 --- a/resolve.c +++ b/resolve.c @@ -12344,7 +12344,7 @@ resolve_typebound_procedures (gfc_symbol* derived) super_type = gfc_get_derived_super_type (derived); if (super_type) - resolve_typebound_procedures (super_type); + resolve_symbol (super_type); resolve_bindings_derived = derived; resolve_bindings_result = SUCCESS; diff --git a/gfortran.h b/gfortran.h index 16751b4..af2b45a 100644 --- a/gfortran.h +++ b/gfortran.h @@ -810,6 +810,9 @@ typedef struct /* Attributes set by compiler extensions (!GCC$ ATTRIBUTES). */ unsigned ext_attr:EXT_ATTR_NUM; + /* Used to avoid multiple resolutions of a single symbol. */ + unsigned resolved:1; + /* The namespace where the attribute has been set. */ struct gfc_namespace *volatile_ns, *asynchronous_ns; } diff --git a/resolve.c b/resolve.c index d6bae43..3b74c6f 100644 --- a/resolve.c +++ b/resolve.c @@ -11051,11 +11051,6 @@ resolve_fl_var_and_proc (gfc_symbol *sym, int mp_flag) { gfc_array_spec *as; - /* Avoid double diagnostics for function result symbols. */ - if ((sym->result || sym->attr.result) && !sym->attr.dummy - && (sym->ns != gfc_current_ns)) - return SUCCESS; - if (sym->ts.type == BT_CLASS && sym->attr.class_ok) as = CLASS_DATA (sym)->as; else @@ -13170,6 +13165,10 @@ resolve_symbol (gfc_symbol *sym) gfc_array_spec *as; bool saved_specification_expr; + if (sym->attr.resolved) + return; + sym->attr.resolved = 1; + if (sym->attr.artificial) return; @@ -13779,7 +13778,6 @@ resolve_symbol (gfc_symbol *sym) described in 14.7.5, to those variables that have not already been assigned one. */ if (sym->ts.type == BT_DERIVED - && sym->ns == gfc_current_ns && !sym->value && !sym->attr.allocatable && !sym->attr.alloc_comp)