From patchwork Sun Jan 6 11:40:31 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Botcazou X-Patchwork-Id: 209741 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 0828A2C0086 for ; Sun, 6 Jan 2013 22:42: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=1358077365; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Received:From:To:Subject:Date:Message-ID:User-Agent:MIME-Version: Content-Type:Content-Transfer-Encoding:Mailing-List:Precedence: List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender: Delivered-To; bh=98S9lE8snoAQ2QIkR+oGkZ0SvYM=; b=wMJrAxLsjLxKSNU VZUHSsvL2Hk56GE6MM4sppWS+G1ENizmIwId9wtrMX9/UpVWFDs68Sj7s/u+ADwe 6NNbGunbLWtZa3lUVYkxGgQ7/kGmcuxudOpNwaZt9QiaIssFFPfFnJmRwcFBK/2R MuAkuoJzdNarwSlIA3NXw2YrBg2E= 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:From:To:Subject:Date:Message-ID:User-Agent:MIME-Version:Content-Type:Content-Transfer-Encoding:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=QHkDD2s04AJ7TqsdULYQhRfI+EjfNkMNL5jWZdqkRUhSLoyg0L7T395rx8Krhl IUsoTa2ltIwDc9NmJX7O8tWP58XolauasSN6pVeST2NA38Sys0Hj3RJDtYvNhwip TxFBH4HHS5STY371vEIf8JTqOQqS++Pn9kdT3o4dZFJ4E=; Received: (qmail 29917 invoked by alias); 6 Jan 2013 11:42:38 -0000 Received: (qmail 29873 invoked by uid 22791); 6 Jan 2013 11:42:38 -0000 X-SWARE-Spam-Status: No, hits=-2.2 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; Sun, 06 Jan 2013 11:42:32 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id 3CB7229002B for ; Sun, 6 Jan 2013 12:42:40 +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 YoKfZ66D-FDC for ; Sun, 6 Jan 2013 12:42:40 +0100 (CET) Received: from polaris.localnet (bon31-6-88-161-99-133.fbx.proxad.net [88.161.99.133]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mel.act-europe.fr (Postfix) with ESMTP id 05F22290001 for ; Sun, 6 Jan 2013 12:42:39 +0100 (CET) From: Eric Botcazou To: gcc-patches@gcc.gnu.org Subject: [Ada] Fix glitch in -gnatR output Date: Sun, 06 Jan 2013 12:40:31 +0100 Message-ID: <1431728.fEu6o3pO4z@polaris> User-Agent: KMail/4.7.2 (Linux/3.1.10-1.16-desktop; KDE/4.7.2; x86_64; ; ) MIME-Version: 1.0 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 When the discriminant of a record type comes from a parent type, the size of the type isn't properly displayed in the -gnatR output. Fixed thusly, tested on x86_64-suse-linux, applied on mainline. 2013-01-06 Eric Botcazou * gcc-interface/decl.c (annotate_value) : Be prepared for discriminants inherited from parent record types. Index: gcc-interface/decl.c =================================================================== --- gcc-interface/decl.c (revision 194926) +++ gcc-interface/decl.c (working copy) @@ -4965,7 +4965,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entit } } - /* If this is a record type or subtype, call elaborate_expression_1 on + /* If this is a record type or subtype, call elaborate_expression_2 on any field position. Do this for both global and local types. Skip any fields that we haven't made trees for to avoid problems with class wide types. */ @@ -7286,15 +7286,22 @@ annotate_value (tree gnu_size) case COMPONENT_REF: /* The only case we handle here is a simple discriminant reference. */ - if (TREE_CODE (TREE_OPERAND (gnu_size, 0)) == PLACEHOLDER_EXPR - && TREE_CODE (TREE_OPERAND (gnu_size, 1)) == FIELD_DECL - && DECL_DISCRIMINANT_NUMBER (TREE_OPERAND (gnu_size, 1))) - return Create_Node (Discrim_Val, - annotate_value (DECL_DISCRIMINANT_NUMBER - (TREE_OPERAND (gnu_size, 1))), - No_Uint, No_Uint); - else - return No_Uint; + if (DECL_DISCRIMINANT_NUMBER (TREE_OPERAND (gnu_size, 1))) + { + tree n = DECL_DISCRIMINANT_NUMBER (TREE_OPERAND (gnu_size, 1)); + + /* Climb up the chain of successive extensions, if any. */ + while (TREE_CODE (TREE_OPERAND (gnu_size, 0)) == COMPONENT_REF + && DECL_NAME (TREE_OPERAND (TREE_OPERAND (gnu_size, 0), 1)) + == parent_name_id) + gnu_size = TREE_OPERAND (gnu_size, 0); + + if (TREE_CODE (TREE_OPERAND (gnu_size, 0)) == PLACEHOLDER_EXPR) + return + Create_Node (Discrim_Val, annotate_value (n), No_Uint, No_Uint); + } + + return No_Uint; CASE_CONVERT: case NON_LVALUE_EXPR: return annotate_value (TREE_OPERAND (gnu_size, 0));