From patchwork Wed Dec 5 11:09:35 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud Charlet X-Patchwork-Id: 203854 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 6EB382C00C4 for ; Wed, 5 Dec 2012 22:09:44 +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=1355310584; 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=yCirEddRpgIzXrg3Umh4 kdUfdzE=; b=XyWcLrPkY0piwrnHmR1jmC4U9U6j/P5X5ofmp6CfvrC2usNXNlNv 6sqoe/QqB6CzkfsO+Z8d72ovPGmsFya3rj40ekz1sSBg3La6UHu9yByZgBdkTwxp u7O7EqYsKqlRWNvPE4ogwoe+42b0hQCrueBTrY4HynoM0kTZlBUxlKw= 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=wOnTujf+5u6tIzVJ/bkfc+j9RMwnHYHT/dshPLaLhqcj/sBeMbvM+OLjMqEiyg ZV8NbO1z1fJVsY0svKLGnEGp7Sk5CRWQ3obMbLpBlgnzg6Dj+wyg+q+xHnk3h9XV 7DOtkdhsJHCW4dCIRQXD5/xE/y5m/AHCFa+euiJ2zFEoI=; Received: (qmail 13605 invoked by alias); 5 Dec 2012 11:09:41 -0000 Received: (qmail 13595 invoked by uid 22791); 5 Dec 2012 11:09:40 -0000 X-SWARE-Spam-Status: No, hits=-1.9 required=5.0 tests=AWL, BAYES_00, RCVD_IN_HOSTKARMA_NO 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; Wed, 05 Dec 2012 11:09:36 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id A57342E2CD; Wed, 5 Dec 2012 06:09:35 -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 sUf1BXaQT02q; Wed, 5 Dec 2012 06:09:35 -0500 (EST) Received: from kwai.gnat.com (kwai.gnat.com [205.232.38.4]) by rock.gnat.com (Postfix) with ESMTP id 8A0CE2E0E1; Wed, 5 Dec 2012 06:09:35 -0500 (EST) Received: by kwai.gnat.com (Postfix, from userid 4192) id 8512C919E3; Wed, 5 Dec 2012 06:09:35 -0500 (EST) Date: Wed, 5 Dec 2012 06:09:35 -0500 From: Arnaud Charlet To: gcc-patches@gcc.gnu.org Cc: Ed Schonberg Subject: [Ada] Ada 2012 AIo5-014: no null exclusion on allocator with subtype indication Message-ID: <20121205110935.GA23612@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 patch implements properly the rule given in this Ada issue. The check is purely syntactic and does not depend on whether the designated type is itself a null excluding access type. Compiling the following in Ada 2012 mode must yield: alloc.adb:23:16: an allocator with a subtype indication cannot have a null exclusion --- -- AI05-104 : an uninitialzed allocated cannot carry a null exclusion. procedure Alloc is begin declare type R (D : Integer) is record Val : Integer; end record; type Ptr is not null access all R; begin if new Ptr /= null then -- OK raise Program_Error; end if; end; declare type T is tagged null record; type Ptr is access all T; type Link is access all Ptr; Thing : Link; begin Thing := new not null Ptr; -- Error end; end; Tested on x86_64-pc-linux-gnu, committed on trunk 2012-12-05 Ed Schonberg * par-ch4.adb (P_Allocator): In Ada 2012 (AI05-0104) an uninitialized allocator cannot carry an explicit not null indicator. * sem_ch4.adb (Analyze_Allocator): Remove code that implements the check for AI05-0104, the check is syntactic and performed in the parser. Index: par-ch4.adb =================================================================== --- par-ch4.adb (revision 194207) +++ par-ch4.adb (working copy) @@ -2928,6 +2928,18 @@ Set_Expression (Alloc_Node, P_Subtype_Indication (Type_Node, Null_Exclusion_Present)); + + -- AI05-0104 : an explicit null exclusion is not allowed for an + -- allocator without initialization. In previous versions of the + -- language it just raises constraint error. + + if Ada_Version >= Ada_2012 + and then Null_Exclusion_Present + then + Error_Msg_N + ("an allocator with a subtype indication " + & "cannot have a null exclusion", Alloc_Node); + end if; end if; return Alloc_Node; Index: sem_ch4.adb =================================================================== --- sem_ch4.adb (revision 194204) +++ sem_ch4.adb (working copy) @@ -631,12 +631,7 @@ Reason => CE_Null_Not_Allowed); begin - if Ada_Version >= Ada_2012 then - Error_Msg_N - ("an uninitialized allocator cannot have" - & " a null exclusion", N); - - elsif Expander_Active then + if Expander_Active then Insert_Action (N, Not_Null_Check); Analyze (Not_Null_Check);