From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29583 invoked by alias); 8 Apr 2011 20:22:32 -0000 Received: (qmail 29560 invoked by uid 22791); 8 Apr 2011 20:22:30 -0000 X-SWARE-Spam-Status: No, hits=-1.9 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from mel.act-europe.fr (HELO mel.act-europe.fr) (194.98.77.210) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 08 Apr 2011 20:21:58 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id 189B9290008 for ; Fri, 8 Apr 2011 22:21:57 +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 i-ptcKmeYLv0 for ; Fri, 8 Apr 2011 22:21:54 +0200 (CEST) Received: from [192.168.1.2] (bon31-9-83-155-120-49.fbx.proxad.net [83.155.120.49]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mel.act-europe.fr (Postfix) with ESMTP id 0B20ECB021E for ; Fri, 8 Apr 2011 22:21:54 +0200 (CEST) From: Eric Botcazou To: gcc-patches@gcc.gnu.org Subject: [Ada] Fix ICE on array type with aggregate component as bound Date: Fri, 08 Apr 2011 20:22:00 -0000 User-Agent: KMail/1.9.9 MIME-Version: 1.0 Content-Type: Multipart/Mixed; boundary="Boundary-00=_X52nNLq64GB2Bat" Message-Id: <201104082221.43317.ebotcazou@adacore.com> Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org X-SW-Source: 2011-04/txt/msg00660.txt.bz2 --Boundary-00=_X52nNLq64GB2Bat Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline Content-length: 656 The compiler aborts on the declaration of an array type whose upper bound is a component of an aggregate whose nominal subtype is a discriminated record type which contains a component whose nominal subtype is a volatile discriminated record type with a variant part and a size clause. Tested on i586-suse-linux, applied on the mainline. 2011-04-08 Eric Botcazou * gcc-interface/trans.c (Identifier_to_gnu): Do not return initializers of aggregate types that contain a placeholder. 2011-04-08 Eric Botcazou * gnat.dg/aggr17.adb: New test. * gnat.dg/aggr18.adb: Likewise. -- Eric Botcazou --Boundary-00=_X52nNLq64GB2Bat Content-Type: text/x-diff; charset="iso 8859-15"; name="p.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="p.diff" Content-length: 1076 Index: gcc-interface/trans.c =================================================================== --- gcc-interface/trans.c (revision 172166) +++ gcc-interface/trans.c (working copy) @@ -1058,10 +1058,14 @@ Identifier_to_gnu (Node_Id gnat_node, tr /* If we have a constant declaration and its initializer, try to return the latter to avoid the need to call fold in lots of places and the need for - elaboration code if this identifier is used as an initializer itself. */ + elaboration code if this identifier is used as an initializer itself. + Don't do it for aggregate types that contain a placeholder since their + initializers cannot be manipulated easily. */ if (TREE_CONSTANT (gnu_result) && DECL_P (gnu_result) - && DECL_INITIAL (gnu_result)) + && DECL_INITIAL (gnu_result) + && !(AGGREGATE_TYPE_P (TREE_TYPE (gnu_result)) + && type_contains_placeholder_p (TREE_TYPE (gnu_result)))) { bool constant_only = (TREE_CODE (gnu_result) == CONST_DECL && !DECL_CONST_CORRESPONDING_VAR (gnu_result)); --Boundary-00=_X52nNLq64GB2Bat Content-Type: text/x-adasrc; charset="iso 8859-15"; name="aggr17.adb" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="aggr17.adb" Content-length: 554 -- { dg-do compile } -- { dg-options "-gnatws" } procedure Aggr17 is type Enum is (A, B); type Rec (D : Enum := Enum'First) is record case D is when A => X : Integer; when B => null; end case; end record; for Rec'Size use 128; pragma Volatile (Rec); type Config_T (D : Enum := Enum'First) is record N : Natural; R : Rec (D); end record; C : constant Config_T := (D => A, N => 1, R => (D => A, X => 0)); type Arr is array (Natural range 1 .. C.N) of Boolean; begin null; end; --Boundary-00=_X52nNLq64GB2Bat Content-Type: text/x-adasrc; charset="iso 8859-15"; name="aggr18.adb" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="aggr18.adb" Content-length: 545 -- { dg-do compile } -- { dg-options "-gnatws" } procedure Aggr18 is type Enum is (A, B); type Rec (D : Enum := Enum'First) is record case D is when A => X : Integer; when B => null; end case; end record; for Rec'Size use 128; pragma Volatile (Rec); type Config_T (D : Enum := Enum'First) is record N : Natural; R : Rec (D); end record; C : Config_T := (D => A, N => 1, R => (D => A, X => 0)); type Arr is array (Natural range 1 .. C.N) of Boolean; begin null; end; --Boundary-00=_X52nNLq64GB2Bat--