From patchwork Thu Oct 10 10:59:27 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud Charlet X-Patchwork-Id: 282202 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 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 96E852C0126 for ; Thu, 10 Oct 2013 21:59:36 +1100 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:mime-version:content-type; q=dns; s=default; b=a0vU7Y9OhWAmt+cK1zJGp4PN0ZHHqlKWL8YsDVdlF30+N1rxLf WYeaakj0xfCMjpT77AELr2HGWgC2aToKTVMAmVqO/jpEmGxn55OPt4Mg6Vk4Yj/W DbEwOr8J+w166icidRQQL5MPUhLeJNd9zYkEuf8/uQb7wdl3hHhUHicro= 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:date :from:to:cc:subject:message-id:mime-version:content-type; s= default; bh=TQwqRWa3ABW8B4vGfyoWVaRTINs=; b=nI1+FDR70HIxs+/zDmyR +xn1WNFAgQ3Zwj8ZG05AbmbgQc0DdrGKR77B7NMFmkOocv7nq0X8m1lT/c0hLI00 0MjkWyvy2pNJh7nx89tGc41G0doK5NRQEhBb2eZCHHbLX94jrz75Qdjpa83yyL5o uW9VagVSSCGyOVZc17l3MpE= Received: (qmail 12261 invoked by alias); 10 Oct 2013 10:59:30 -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 12252 invoked by uid 89); 10 Oct 2013 10:59:30 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham version=3.3.2 X-HELO: rock.gnat.com Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Thu, 10 Oct 2013 10:59:29 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 1E6C8116183; Thu, 10 Oct 2013 06:59:49 -0400 (EDT) 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 aMGUrCJo4Gl7; Thu, 10 Oct 2013 06:59:49 -0400 (EDT) Received: from kwai.gnat.com (unknown [IPv6:2620:20:4000:0:a6ba:dbff:fe26:1f63]) by rock.gnat.com (Postfix) with ESMTP id 0C56B116173; Thu, 10 Oct 2013 06:59:49 -0400 (EDT) Received: by kwai.gnat.com (Postfix, from userid 4192) id DA1DE3FB31; Thu, 10 Oct 2013 06:59:27 -0400 (EDT) Date: Thu, 10 Oct 2013 06:59:27 -0400 From: Arnaud Charlet To: gcc-patches@gcc.gnu.org Cc: Robert Dewar Subject: [Ada] Handle some warning situations with Address aspect Message-ID: <20131010105927.GA10979@adacore.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-06-14) The Address attribute definition clause processing warns when overlaying a small object with a large one, and also avoids giving a warning about the entity not being referenced. This patch applies the same processing to corresponding uses of the Address aspect. The following test program shows the expected warnings being the same for the address aspect and the address definition clause: 1. function addrAP return Integer is 2. X : Integer := 123; 3. Y : Integer with Address => X'Address; 4. Z : Integer; 5. for Z'Address use X'Address; 6. P : Integer := 123; 7. Q : Long_Long_Integer; 8. for Q'Address use P'Address; | >>> warning: "Q" overlays smaller object >>> warning: program execution may be erroneous >>> warning: size of "Q" is 64 >>> warning: size of "P" is 32 9. R : Long_Long_Integer with Address => P'Address; | >>> warning: "R" overlays smaller object >>> warning: program execution may be erroneous >>> warning: size of "R" is 64 >>> warning: size of "P" is 32 10. begin 11. return Y + Z; 12. end addrAP; Tested on x86_64-pc-linux-gnu, committed on trunk 2013-10-10 Robert Dewar * sem_ch13.adb (Analyze_Aspect_Specifications): For Address attribute, consider it to be set in source, because of aliasing considerations. (Analyze_Attribute_Definition_Clause): For the purpose of warning on overlays, take into account the aspect case. Index: sem_ch13.adb =================================================================== --- sem_ch13.adb (revision 203347) +++ sem_ch13.adb (working copy) @@ -1593,6 +1593,18 @@ goto Continue; end if; + -- For case of address aspect, we don't consider that we + -- know the entity is never set in the source, since it is + -- is likely aliasing is occurring. + + -- Note: one might think that the analysis of the resulting + -- attribute definition clause would take care of that, but + -- that's not the case since it won't be from source. + + if A_Id = Aspect_Address then + Set_Never_Set_In_Source (E, False); + end if; + -- Construct the attribute definition clause Aitem := @@ -3474,7 +3486,8 @@ -- and alignment of the overlaying variable. We defer this -- check till after code generation to take full advantage -- of the annotation done by the back end. This entry is - -- only made if the address clause comes from source. + -- only made if the address clause comes from source or + -- from an aspect clause (which is still from source). -- If the entity has a generic type, the check will be -- performed in the instance if the actual type justifies @@ -3482,7 +3495,8 @@ -- prevent spurious warnings. if Address_Clause_Overlay_Warnings - and then Comes_From_Source (N) + and then (Comes_From_Source (N) + or else From_Aspect_Specification (N)) and then Present (O_Ent) and then Is_Object (O_Ent) then