From patchwork Mon May 2 10:36:52 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud Charlet X-Patchwork-Id: 617461 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 3qz12f0M2kz9sRZ for ; Mon, 2 May 2016 20:37:13 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=w4ttz9KV; dkim-atps=neutral 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=fmij3qOG8DCbs0KlEqrGIMiHFuLg2ZLjuRfeR5RQex0REurUYO UI2KTBsR1KyJdkoM/zoZf/Fr6lnJ2FeqT5fWQ3SoQa7EKE5he1x1ZAguXbiGy0me xJ7z2PbLpoH0hpghuhRygD1ecXcF0jw31K1HkQvKmoqGnGDLHwFdChuag= 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=qpLzzQXAwd2iMGIRYDpzWzqsnSo=; b=w4ttz9KVoRvU5s/X/7k4 i8gybFmG7P3A70S41gfWmPFI8SuOZSSnTeHrE7vg0lqjuK4DP5w6eWWFHr3jgbeH eI1ARjyOmvjcCsCuxLettUIKcBXJqC8lFhGPC9gr09tjeY7X9z0lresckkEc2v1C 8QQ3giNxUnvvORVnPlD4KZQ= Received: (qmail 15289 invoked by alias); 2 May 2016 10:37:04 -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 15237 invoked by uid 89); 2 May 2016 10:37:04 -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_50, KAM_LAZY_DOMAIN_SECURITY, RCVD_IN_DNSWL_NONE autolearn=no version=3.3.2 spammy=40k, 4.0k, 40K, 4.0K 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; Mon, 02 May 2016 10:36:54 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 57FA7116B43; Mon, 2 May 2016 06:36:52 -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 P4qlOKwUWAYu; Mon, 2 May 2016 06:36:52 -0400 (EDT) Received: from tron.gnat.com (tron.gnat.com [205.232.38.10]) by rock.gnat.com (Postfix) with ESMTP id 480AB116B3D; Mon, 2 May 2016 06:36:52 -0400 (EDT) Received: by tron.gnat.com (Postfix, from userid 4192) id 470CF30C; Mon, 2 May 2016 06:36:52 -0400 (EDT) Date: Mon, 2 May 2016 06:36:52 -0400 From: Arnaud Charlet To: gcc-patches@gcc.gnu.org Cc: Ed Schonberg Subject: [Ada] Remove spurious accessibility check for aggregate component Message-ID: <20160502103652.GA22309@adacore.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) This patch removes an accessibility check that was improperly applied, via a type conversion, to an an operand that is an access parameter that also requires a non-null check. Test in ACATS 4.0K C3A0030. Tested on x86_64-pc-linux-gnu, committed on trunk 2016-05-02 Ed Schonberg * sem_util.adb (Aggregate_Constraint_Checks): Separate accessibility checks and non-null checks for aggregate components, to prevent spurious accessibility errors. Index: sem_util.adb =================================================================== --- sem_util.adb (revision 235732) +++ sem_util.adb (working copy) @@ -326,21 +326,19 @@ -- Ada 2005 (AI-230): Generate a conversion to an anonymous access -- component's type to force the appropriate accessibility checks. - -- Ada 2005 (AI-231): Generate conversion to the null-excluding - -- type to force the corresponding run-time check + -- Ada 2005 (AI-231): Generate conversion to the null-excluding type to + -- force the corresponding run-time check if Is_Access_Type (Check_Typ) - and then ((Is_Local_Anonymous_Access (Check_Typ)) - or else (Can_Never_Be_Null (Check_Typ) - and then not Can_Never_Be_Null (Exp_Typ))) + and then Is_Local_Anonymous_Access (Check_Typ) then Rewrite (Exp, Convert_To (Check_Typ, Relocate_Node (Exp))); Analyze_And_Resolve (Exp, Check_Typ); Check_Unset_Reference (Exp); end if; - -- This is really expansion activity, so make sure that expansion is - -- on and is allowed. In GNATprove mode, we also want check flags to + -- What follows is really expansion activity, so check that expansion + -- is on and is allowed. In GNATprove mode, we also want check flags to -- be added in the tree, so that the formal verification can rely on -- those to be present. In GNATprove mode for formal verification, some -- treatment typically only done during expansion needs to be performed @@ -353,6 +351,13 @@ return; end if; + if Is_Access_Type (Check_Typ) + and then Can_Never_Be_Null (Check_Typ) + and then not Can_Never_Be_Null (Exp_Typ) + then + Install_Null_Excluding_Check (Exp); + end if; + -- First check if we have to insert discriminant checks if Has_Discriminants (Exp_Typ) then