From patchwork Tue Jun 22 16:23:16 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud Charlet X-Patchwork-Id: 56525 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 8333DB6F0E for ; Wed, 23 Jun 2010 02:23:28 +1000 (EST) Received: (qmail 24345 invoked by alias); 22 Jun 2010 16:23:23 -0000 Received: (qmail 24330 invoked by uid 22791); 22 Jun 2010 16:23:20 -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; Tue, 22 Jun 2010 16:23:15 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id 14168CB0202; Tue, 22 Jun 2010 18:23:17 +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 lsFVIe6-l6oo; Tue, 22 Jun 2010 18:23:17 +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 F3864CB01DB; Tue, 22 Jun 2010 18:23:16 +0200 (CEST) Received: by saumur.act-europe.fr (Postfix, from userid 525) id EC4A9D9BB4; Tue, 22 Jun 2010 18:23:16 +0200 (CEST) Date: Tue, 22 Jun 2010 18:23:16 +0200 From: Arnaud Charlet To: gcc-patches@gcc.gnu.org Cc: Thomas Quinot Subject: [Ada] Crash on aggregate with discriminant expanded name in default expression Message-ID: <20100622162316.GA25559@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 change fixes a compiler crash in the processing of aggregates with boxes, in the case where some default expression contains a reference to a discriminant of the type written as an expanded name rather than an identifier. The following compilation must be accepted quietly: $ gcc -c exp_name_discr_in_default.adb pragma Ada_2005; procedure Exp_Name_Discr_In_Default is type Rule_Tracker (Size : Positive) is record Still_Active : Natural := Rule_Tracker.Size; end record; Tracker_Size : constant Positive := 1234; procedure P (X : Rule_Tracker) is begin null; end; begin P ((Size => Tracker_Size, others => <>)); end Exp_Name_Discr_In_Default; Tested on x86_64-pc-linux-gnu, committed on trunk 2010-06-22 Thomas Quinot * exp_aggr.adb (Rewrite_Discriminant): Fix predicate used to identify reference to discriminant (can be an expanded name as well as an identifier). Index: exp_aggr.adb =================================================================== --- exp_aggr.adb (revision 161195) +++ exp_aggr.adb (working copy) @@ -2427,7 +2427,7 @@ package body Exp_Aggr is function Rewrite_Discriminant (Expr : Node_Id) return Traverse_Result is begin - if Nkind (Expr) = N_Identifier + if Is_Entity_Name (Expr) and then Present (Entity (Expr)) and then Ekind (Entity (Expr)) = E_In_Parameter and then Present (Discriminal_Link (Entity (Expr)))