From patchwork Wed Apr 8 10:29:36 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mikael Morin X-Patchwork-Id: 459184 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]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id A718F140077 for ; Wed, 8 Apr 2015 20:30:01 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass reason="1024-bit key; unprotected key" header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=TS3Bw2X3; dkim-adsp=none (unprotected policy); dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:cc:subject:references :in-reply-to:content-type; q=dns; s=default; b=lqyAfv7rZbT7NYZ8o 2xiLvppue1paeYKY6xb2uvlOezYNuviVsI3uqFD/YEBfUNCYlO1azRZDzLxUr3Qn AaFBESow02YT9hn+OTRSPRIa9Iry9jtJXEgk0zxeBz6TRPi6ipvUy+YpIe/j9YpC eqG4R+mKE4yXmTrIT8ClCF1eWI= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:cc:subject:references :in-reply-to:content-type; s=default; bh=F9n9kgQSmbYax0Rf/MuF/Kr zDS4=; b=TS3Bw2X3z6WbrBJKLoTJ4GAz+v4Xk2WmSSRfMKxBdXN5icAeMgT3Rrj c/NT1xJuoaBMqiWn8+MVOyAUCZEuPhK8BvuM3+jw1hK6Xu9tE79ThYrRNoTiPCOj MF+mv0+CamuyqlOhqhE+O7Sye1piw0Si0d+OMqbjapSBiVS581EI= Received: (qmail 95672 invoked by alias); 8 Apr 2015 10:29:54 -0000 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 Received: (qmail 95649 invoked by uid 89); 8 Apr 2015 10:29:53 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.4 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE, RCVD_IN_JMF_BR, SPF_PASS, T_RP_MATCHES_RCVD autolearn=no version=3.3.2 X-Spam-User: qpsmtpd, 2 recipients X-HELO: smtp26.services.sfr.fr Received: from smtp26.services.sfr.fr (HELO smtp26.services.sfr.fr) (93.17.128.163) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Wed, 08 Apr 2015 10:29:52 +0000 Received: from filter.sfr.fr (localhost [86.72.15.254]) by msfrf2604.sfr.fr (SMTP Server) with ESMTP id 592501C02EC59; Wed, 8 Apr 2015 12:29:49 +0200 (CEST) Authentication-Results: sfrmc.priv.atos.fr; dkim=none (no signature); dkim-adsp=none (no policy) header.from=mikael.morin@sfr.fr Received: from tolstoi.localhost (254.15.72.86.rev.sfr.net [86.72.15.254]) (using TLSv1.2 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) by msfrf2604.sfr.fr (SMTP Server) with ESMTP id EE6041C02E83E; Wed, 8 Apr 2015 12:29:47 +0200 (CEST) X-SFR-UUID: 20150408102947976.EE6041C02E83E@msfrf2604.sfr.fr Message-ID: <55250310.50201@sfr.fr> Date: Wed, 08 Apr 2015 12:29:36 +0200 From: Mikael Morin User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 MIME-Version: 1.0 To: Evangelos Drikos , fortran@gcc.gnu.org CC: gcc-patches@gcc.gnu.org Subject: Re: pr59016 References: <5522CFEC.4070802@sfr.fr> <5523CCB0.5090707@sfr.fr> In-Reply-To: <5523CCB0.5090707@sfr.fr> X-IsSubscribed: yes Le 07/04/2015 14:25, Mikael Morin a écrit : > Le 06/04/2015 20:26, Mikael Morin a écrit : >> Regarding the patch, I don't understand why the existing symbol >> restoration code doesn't work here (see >> gfc_restore_last_undo_checkpoint, restore_old_symbol). I have to >> investigate more. > > I think the problem is the usage of gfc_find_symbol in > gfc_match_decl_type_spec. > In opposition to the gfc_get_* family of functions, the gfc_find_* > functions don't version symbols, so that changes made to the symbol are > not thrown away when the statement is rejected. > So something like the following should be preferred over Evangelos' patch. Except that the following ... ahem ... doesn't work. Mikael Index: decl.c =================================================================== --- decl.c (révision 221654) +++ decl.c (copie de travail) @@ -2840,7 +2840,7 @@ gfc_match_decl_type_spec (gfc_typespec *ts, int im if (ts->kind != -1) { gfc_get_ha_symbol (name, &sym); - if (sym->generic && gfc_find_symbol (dt_name, NULL, 0, &dt_sym)) + if (sym->generic && gfc_get_symbol (dt_name, NULL, &dt_sym)) { gfc_error ("Type name %qs at %C is ambiguous", name); return MATCH_ERROR; @@ -2850,10 +2850,11 @@ gfc_match_decl_type_spec (gfc_typespec *ts, int im } else if (ts->kind == -1) { - int iface = gfc_state_stack->previous->state != COMP_INTERFACE - || gfc_current_ns->has_import_set; - gfc_find_symbol (name, NULL, iface, &sym); - if (sym && sym->generic && gfc_find_symbol (dt_name, NULL, 1, &dt_sym)) + gfc_get_ha_symbol (name, &sym); + if (sym == NULL || sym->gfc_new) + return MATCH_NO; + + if (sym && sym->generic && gfc_get_ha_symbol (dt_name, &dt_sym)) { gfc_error ("Type name %qs at %C is ambiguous", name); return MATCH_ERROR; @@ -2862,8 +2863,6 @@ gfc_match_decl_type_spec (gfc_typespec *ts, int im dt_sym = gfc_find_dt_in_generic (sym); ts->kind = 0; - if (sym == NULL) - return MATCH_NO; } if ((sym->attr.flavor != FL_UNKNOWN @@ -2885,12 +2884,13 @@ gfc_match_decl_type_spec (gfc_typespec *ts, int im && !gfc_add_function (&sym->attr, sym->name, NULL)) return MATCH_ERROR; - if (!dt_sym) + if (!dt_sym || dt_sym->gfc_new) { gfc_interface *intr, *head; /* Use upper case to save the actual derived-type symbol. */ - gfc_get_symbol (dt_name, NULL, &dt_sym); + if (!dt_sym) + gfc_get_symbol (dt_name, NULL, &dt_sym); dt_sym->name = gfc_get_string (sym->name); head = sym->generic; intr = gfc_get_interface ();