From patchwork Mon Jan 30 12:16:46 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud Charlet X-Patchwork-Id: 138556 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 B15C8B6F62 for ; Mon, 30 Jan 2012 23:17:26 +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=1328530647; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Received:Received:Date:From:To:Cc:Subject:Message-ID: MIME-Version:Content-Type:Content-Disposition:User-Agent: Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:Sender:Delivered-To; bh=JlrqXjuD4YNmQHeByQUx jWAqUkE=; b=Iop/BOg76vlkT3leYjj4gAoRb5yllFHxYPZCoOJbgMYtPaBKowxN qsCZxAXtFwEgN7R8AHruOR+2IK+MFtsrVah8OtB/z8hJQwMwVhHdih8M19S6noG2 cAPM0r42bDkgSUQT0v9PfxwCVXzWjQ7myxgfcNuMRbpZwBtHQnhYq28= 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:Received:Received:Date:From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type:Content-Disposition:User-Agent:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=v/+Xgn8AMI5ZlYEXqpHNRThQ9dwvSUCaS+ubDhSjwiLxOAcsMuROruN9ydqYtz 4xVqAUIvt9Vvh5Gt4uvnWtd+t1f+3SckVnE08qjUH81Zhtx6prh986cnn46ayd+U CeR5Hsrcn1sRcraUperFf9ittvsbVEoZFlfrTtHB+9egY=; Received: (qmail 30724 invoked by alias); 30 Jan 2012 12:17:15 -0000 Received: (qmail 30712 invoked by uid 22791); 30 Jan 2012 12:17:12 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 30 Jan 2012 12:16:47 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id B821D2BB085; Mon, 30 Jan 2012 07:16:46 -0500 (EST) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id ZHoHDnIUbN8H; Mon, 30 Jan 2012 07:16:46 -0500 (EST) Received: from kwai.gnat.com (kwai.gnat.com [205.232.38.4]) by rock.gnat.com (Postfix) with ESMTP id 8E3DF2BB081; Mon, 30 Jan 2012 07:16:46 -0500 (EST) Received: by kwai.gnat.com (Postfix, from userid 4192) id 81C4492BF6; Mon, 30 Jan 2012 07:16:46 -0500 (EST) Date: Mon, 30 Jan 2012 07:16:46 -0500 From: Arnaud Charlet To: gcc-patches@gcc.gnu.org Cc: Javier Miranda Subject: [Ada] PR ada/15846 Reject self-renaming of subprogram declaration Message-ID: <20120130121646.GA29500@adacore.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-06-14) 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 The compiler does not report an error on the self renaming of a subprogram declaration when the renamed subprogram is referenced through its expanded name. After this patch the following test is rejected by the compiler: package Renamings1 is type T1 is tagged null record; function "=" (left, right : in T1) return Boolean renames Renamings1."="; end Renamings1; $ gcc -c renamings1.ads renamings1.ads:5:06: subprogram cannot rename itself Tested on x86_64-pc-linux-gnu, committed on trunk 2012-01-30 Javier Miranda PR ada/15846 * sem_ch8.adb (Analyze_Subprogram_Renaming): Handle self-renaming when the renamed entity is referenced using its expanded name. Index: sem_ch8.adb =================================================================== --- sem_ch8.adb (revision 183694) +++ sem_ch8.adb (working copy) @@ -6,7 +6,7 @@ -- -- -- B o d y -- -- -- --- Copyright (C) 1992-2011, Free Software Foundation, Inc. -- +-- Copyright (C) 1992-2012, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -2665,7 +2665,10 @@ if not Is_Actual and then (Old_S = New_S or else (Nkind (Nam) /= N_Expanded_Name - and then Chars (Old_S) = Chars (New_S))) + and then Chars (Old_S) = Chars (New_S)) + or else (Nkind (Nam) = N_Expanded_Name + and then Entity (Prefix (Nam)) = Current_Scope + and then Chars (Selector_Name (Nam)) = Chars (New_S))) then Error_Msg_N ("subprogram cannot rename itself", N); end if;