From patchwork Sat Mar 26 10:14:32 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Botcazou X-Patchwork-Id: 88461 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 A2AF7B6FAB for ; Sat, 26 Mar 2011 21:19:23 +1100 (EST) Received: (qmail 26927 invoked by alias); 26 Mar 2011 10:19:18 -0000 Received: (qmail 26909 invoked by uid 22791); 26 Mar 2011 10:19:16 -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; Sat, 26 Mar 2011 10:19:10 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id B04A42900AF for ; Sat, 26 Mar 2011 11:19:09 +0100 (CET) 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 DIYMx2Ccw7JL for ; Sat, 26 Mar 2011 11:19:06 +0100 (CET) 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 A059F2900B0 for ; Sat, 26 Mar 2011 11:19:06 +0100 (CET) From: Eric Botcazou To: gcc-patches@gcc.gnu.org Subject: [Ada] Fix crash on declaration of constant with discriminated type Date: Sat, 26 Mar 2011 11:14:32 +0100 User-Agent: KMail/1.9.9 MIME-Version: 1.0 Message-Id: <201103261114.32966.ebotcazou@adacore.com> 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 compiler crashes on the declaration of a constant with discriminated record type and variable size, if the constant is initialized to an aggregate which assigns the length of an array with variable size to a discriminant. The problem is again an incorrect sharing of a tree node between two types. Tested on i586-suse-linux, applied on the mainline. 2011-03-26 Eric Botcazou * gcc-interface/decl.c (gnat_to_gnu_entity) : Create TYPE_DECL for the padded type built to support a specified size or alignment. 2011-03-26 Eric Botcazou * gnat.dg/discr27.ad[sb]: New test. Index: gcc-interface/decl.c =================================================================== --- gcc-interface/decl.c (revision 171552) +++ gcc-interface/decl.c (working copy) @@ -911,9 +911,20 @@ gnat_to_gnu_entity (Entity_Id gnat_entit size of the object. */ gnu_object_size = gnu_size ? gnu_size : TYPE_SIZE (gnu_type); if (gnu_size || align > 0) - gnu_type = maybe_pad_type (gnu_type, gnu_size, align, gnat_entity, - false, false, definition, - gnu_size ? true : false); + { + tree orig_type = gnu_type; + + gnu_type = maybe_pad_type (gnu_type, gnu_size, align, gnat_entity, + false, false, definition, + gnu_size ? true : false); + + /* If a padding record was made, declare it now since it will + never be declared otherwise. This is necessary to ensure + that its subtrees are properly marked. */ + if (gnu_type != orig_type && !DECL_P (TYPE_NAME (gnu_type))) + create_type_decl (TYPE_NAME (gnu_type), gnu_type, NULL, true, + debug_info_p, gnat_entity); + } /* If this is a renaming, avoid as much as possible to create a new object. However, in several cases, creating it is required.