From patchwork Fri Feb 6 20:31:56 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mikael Morin X-Patchwork-Id: 437457 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 C09DE14016B for ; Sat, 7 Feb 2015 07:33:11 +1100 (AEDT) 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:subject:content-type; q= dns; s=default; b=Z9jkyihf0P1iAlyJkLJXPPxpqbfmiYjaCRz+ORH5QzYdsG 9EJnjVppDAczet97NBwrR5zoOK0GlsX4UrhEVMF2bMeBijGN9KyqAolL4eIkCUjI tuUd8iqeDWPjQlQRZpQfSSyl3RvsGMBbh+PNoipmh4KO/sa+8A+sI6ebb75Lw= 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:subject:content-type; s= default; bh=dAXZKeRJ8k/AeZure9Ibgha+n4w=; b=pCNoBRsxovh3g38cZXE6 gDUJnWjxY7FNQXAFtz4MxXVCGlsIawJSnbjlxAa/Qi7Texr1n/SrVLfOalwCqxGt kpp/tye5RcXNkwI3eAH85Lmz0KutTVv/za48enlTtXqz5NDk/ABu5k3C7DMSF+9l 6Di476o7KxS4l5s2E7ARKzY= Received: (qmail 22688 invoked by alias); 6 Feb 2015 20:32:08 -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 22671 invoked by uid 89); 6 Feb 2015 20:32:07 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE, SPF_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-Spam-User: qpsmtpd, 2 recipients X-HELO: smtp24.services.sfr.fr Received: from smtp24.services.sfr.fr (HELO smtp24.services.sfr.fr) (93.17.128.81) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Fri, 06 Feb 2015 20:32:06 +0000 Received: from filter.sfr.fr (localhost [86.72.15.254]) by msfrf2404.sfr.fr (SMTP Server) with ESMTP id 099DA70001FE; Fri, 6 Feb 2015 21:32:03 +0100 (CET) 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 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) by msfrf2404.sfr.fr (SMTP Server) with ESMTP id AD17370001FD; Fri, 6 Feb 2015 21:32:02 +0100 (CET) X-SFR-UUID: 20150206203202709.AD17370001FD@msfrf2404.sfr.fr Message-ID: <54D524BC.2090908@sfr.fr> Date: Fri, 06 Feb 2015 21:31:56 +0100 From: Mikael Morin User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 MIME-Version: 1.0 To: gfortran , gcc-patches Subject: [Patch, fortran] PR63744 accept duplicate use-rename X-IsSubscribed: yes Hello, we currently reject programs of the form > > module m > integer :: s > end module m > subroutine s > use m, only: x => s, x => s > end subroutine s with an error stating that S is the name of the current program unit. Interestingly, the duplicate rename is necessary to trigger it. There doesn't seem to be a consensus as to whether it should be accepted, but I think it should be. Quoting Dominique's comment in the PR: > if > > use m, only: A => X > use m, only: B => X > > is valid, I don't see why > > use m, only: A => X > use m, only: A => X > > should not. The problem is we check the original (symbol) name instead of the local (symtree) name. The fix is close to obvious, and should be safe for the branches (this is a regression) Regression tested on x86_64-linux. OK for trunk/4.9/4.8 ? Mikael 2015-02-06 Mikael Morin PR fortran/63744 * module.c (check_for_ambiguous): Change argument type from gfc_symbol to gfc_symtree. Check local (symtree) name instead of original (symbol) name. (read_module): Update caller. 2015-02-06 Mikael Morin PR fortran/63744 gfortran.dg/use_rename_8.f90: New. Index: module.c =================================================================== --- module.c (révision 220107) +++ module.c (copie de travail) @@ -4795,19 +4795,21 @@ read_cleanup (pointer_info *p) /* It is not quite enough to check for ambiguity in the symbols by the loaded symbol and the new symbol not being identical. */ static bool -check_for_ambiguous (gfc_symbol *st_sym, pointer_info *info) +check_for_ambiguous (gfc_symtree *st, pointer_info *info) { gfc_symbol *rsym; module_locus locus; symbol_attribute attr; + gfc_symbol *st_sym; - if (gfc_current_ns->proc_name && st_sym->name == gfc_current_ns->proc_name->name) + if (gfc_current_ns->proc_name && st->name == gfc_current_ns->proc_name->name) { gfc_error ("%qs of module %qs, imported at %C, is also the name of the " - "current program unit", st_sym->name, module_name); + "current program unit", st->name, module_name); return true; } + st_sym = st->n.sym; rsym = info->u.rsym.sym; if (st_sym == rsym) return false; @@ -5037,7 +5039,7 @@ read_module (void) if (st != NULL) { /* Check for ambiguous symbols. */ - if (check_for_ambiguous (st->n.sym, info)) + if (check_for_ambiguous (st, info)) st->ambiguous = 1; else info->u.rsym.symtree = st;