From patchwork Fri Feb 17 14:16:14 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud Charlet X-Patchwork-Id: 141827 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 3C6A6B6F9D for ; Sat, 18 Feb 2012 01:16:40 +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=1330093001; 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=bPmbUuf++uHQKmlg3CQb W+E1/MQ=; b=QUb41XQgoZcB8PcOUUFwRXaoVf4RDEnMuc2AcUUVGwRgVUUJqvQq /cyfwUg+9uY4ynxwxGm1ZG0ae/MWqNObs6mvd3uk9Pbr8/GW4E0ZNvs6qKuIb7ox SuMSefLhwhAP9z9cYJ4MpX0FZ5r9g6i+uuvu26X/SF7HH4s2OuM52Sg= 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=uVKnEQPK1sMGiyjlKQCvsHdLOwDuC6JwFVEZxMD12xNstZRxuRvLDrEo+Y8DfC CxHZ8WCrv35WYLlshYo0WRhcHhfi8xUvJ/jLu74pzd+qLvHZH5whBPGXFAa5SfSg hmcpv4BfS4//CrmPeJvHZLF1Nz00hkq4Z5J/x4OlPLAlo=; Received: (qmail 14895 invoked by alias); 17 Feb 2012 14:16:34 -0000 Received: (qmail 14874 invoked by uid 22791); 17 Feb 2012 14:16:32 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL, BAYES_00, SUBJ_OBFU_PUNCT_FEW 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; Fri, 17 Feb 2012 14:16:15 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 3B3B81C6726; Fri, 17 Feb 2012 09:16:14 -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 cTaPS6iXQwXL; Fri, 17 Feb 2012 09:16:14 -0500 (EST) Received: from kwai.gnat.com (kwai.gnat.com [205.232.38.4]) by rock.gnat.com (Postfix) with ESMTP id 1EF781C6725; Fri, 17 Feb 2012 09:16:14 -0500 (EST) Received: by kwai.gnat.com (Postfix, from userid 4192) id 1EA5292BF6; Fri, 17 Feb 2012 09:16:14 -0500 (EST) Date: Fri, 17 Feb 2012 09:16:14 -0500 From: Arnaud Charlet To: gcc-patches@gcc.gnu.org Cc: Robert Dewar Subject: [Ada] Don't flag No_Obsolescent_Features violations in instances Message-ID: <20120217141614.GA28501@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 This patch avoids flagging violations of the No_Obsolescent_Features restriction in generic instances. Such diagnostics are redundant since the violation will be flagged in the template anyway. The following is a test of this patch gnat.adc contains pragma Restrictions (No_Obsolescent_Features); 1. generic 2. package obsolescent_generic is 3. procedure Initialize; 4. end obsolescent_generic; 1. package body obsolescent_generic is 2. procedure Initialize is 3. A : Integer; 4. B : Integer; 5. for A use at B'address; | >>> violation of restriction "no_obsolescent_features" at gnat.adc:1 6. begin 7. null; 8. end Initialize; 9. end obsolescent_generic; Compiling: obsolescent_instance1.ads 1. package obsolescent_instance1 is 2. procedure Call; 3. end obsolescent_instance1; Compiling: obsolescent_instance1.adb 1. with obsolescent_generic; 2. package body obsolescent_instance1 is 3. package Instance1 is new obsolescent_generic; 4. procedure Call is 5. begin 6. Instance1.Initialize; 7. end Call; 8. end obsolescent_instance1; Prior to this patch, the compilation of the instance resulted in a diagnostic on line 3 of the body (the instantiation). Tested on x86_64-pc-linux-gnu, committed on trunk 2012-02-17 Robert Dewar * restrict.adb (Check_Restriction): Add special handling for No_Obsolescent_Features. Index: restrict.adb =================================================================== --- restrict.adb (revision 184330) +++ restrict.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- -- @@ -532,6 +532,15 @@ elsif not Restrictions.Set (R) then null; + -- Don't complain about No_Obsolescent_Features in an instance, since we + -- will complain on the template, which is much better. Are there other + -- cases like this ??? Do we need a more general mechanism ??? + + elsif R = No_Obsolescent_Features + and then Instantiation_Location (Sloc (N)) /= No_Location + then + null; + -- Here if restriction set, check for violation (either this is a -- Boolean restriction, or a parameter restriction with a value of -- zero and an unknown count, or a parameter restriction with a