From patchwork Mon Oct 18 09:53:32 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud Charlet X-Patchwork-Id: 68155 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 3EFCFB70DF for ; Mon, 18 Oct 2010 20:53:42 +1100 (EST) Received: (qmail 21105 invoked by alias); 18 Oct 2010 09:53:40 -0000 Received: (qmail 21097 invoked by uid 22791); 18 Oct 2010 09:53:39 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL, BAYES_00, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mel.act-europe.fr (HELO mel.act-europe.fr) (212.99.106.210) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 18 Oct 2010 09:53:35 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id E0F15CB0326; Mon, 18 Oct 2010 11:53:32 +0200 (CEST) Received: from mel.act-europe.fr ([127.0.0.1]) by localhost (smtp.eu.adacore.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id lMx-Ai3MGI-N; Mon, 18 Oct 2010 11:53:32 +0200 (CEST) Received: from saumur.act-europe.fr (saumur.act-europe.fr [10.10.0.183]) by mel.act-europe.fr (Postfix) with ESMTP id CE991CB0254; Mon, 18 Oct 2010 11:53:32 +0200 (CEST) Received: by saumur.act-europe.fr (Postfix, from userid 525) id B17E4D9BB4; Mon, 18 Oct 2010 11:53:32 +0200 (CEST) Date: Mon, 18 Oct 2010 11:53:32 +0200 From: Arnaud Charlet To: gcc-patches@gcc.gnu.org Cc: Robert Dewar Subject: [Ada] Fix bad warning for unmodified pragma and unbounded string Message-ID: <20101018095332.GA25805@adacore.com> Mime-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.9i 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 This patch fixes the error of the compiler sometimes giving a warning for a pragma Unmodified when the object is only referenced but has a component of type Unbounded_String. The following test compiles quietly with no switches (it used to give a bogus warning on line 14. 1. with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; 2. procedure Unmodunbs is 3. type Rec is record 4. U : Unbounded_String; 5. end record; 6. S1, S2, s3 : Rec; 7. pragma Unmodified (S2); 8. pragma Unreferenced (S3); 9. 10. U1, U2, U3 : Unbounded_String; 11. pragma Unmodified (U2); 12. pragma Unreferenced (U3); 13. begin 14. S1 := S2; 15. U1 := U2; 16. end; Tested on x86_64-pc-linux-gnu, committed on trunk 2010-10-18 Robert Dewar * sem_util.adb (Note_Possible_Modification): Do not give warning for use of pragma Unmodified unless we are sure this is a modification. Index: sem_util.adb =================================================================== --- sem_util.adb (revision 165614) +++ sem_util.adb (working copy) @@ -9451,7 +9451,10 @@ package body Sem_Util is if Comes_From_Source (Exp) or else Modification_Comes_From_Source then - if Has_Pragma_Unmodified (Ent) then + -- Give warning if pragma unmodified given and we are + -- sure this is a modification. + + if Has_Pragma_Unmodified (Ent) and then Sure then Error_Msg_NE ("?pragma Unmodified given for &!", N, Ent); end if;