From patchwork Mon Nov 11 17:06:23 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Botcazou X-Patchwork-Id: 290418 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]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 751402C009A for ; Tue, 12 Nov 2013 04:07:44 +1100 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type:content-transfer-encoding; q=dns; s= default; b=pvpIoe6rcvW0Fl3ZAZVoUAfhLQ0a7lwDI8i45vfuUqWzF73vK6g54 n/Wf1HS9/YFLJ6emvKkYRWTGBy/XGYgcR5S7sZ+uv2itliZ88Zb6n9pviBrBr4SE 8D3Md5dmXMLlA8TriIB1n14Ryf2LF2/dOtWIVBSYJdXdL8GeR/iWnA= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type:content-transfer-encoding; s=default; bh=eXDTQIkeU91n/Pxuvzh1EB0rYGc=; b=phTCASYJrt/P/Y9m/91++qpVVqcO kQgVEO3h2QFf2iJY76enB0KyPm80RYcOSo+bKd35ZokWatQHuE7sONS3AiUJ1Ubu D1USn0ekD9gyGVl4SVIRsZzZ/SXW29anWuV3q8Q+1SxNh7FgYcvTIdK4xoXu7glK gD9r0QyZxS0jl60= Received: (qmail 3989 invoked by alias); 11 Nov 2013 17:07:35 -0000 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 Received: (qmail 3975 invoked by uid 89); 11 Nov 2013 17:07:34 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.4 required=5.0 tests=AWL, BAYES_50, RDNS_NONE, URIBL_BLOCKED autolearn=no version=3.3.2 X-HELO: smtp.eu.adacore.com Received: from Unknown (HELO smtp.eu.adacore.com) (194.98.77.210) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Mon, 11 Nov 2013 17:07:32 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id B068526A0CF1; Mon, 11 Nov 2013 18:07:23 +0100 (CET) Received: from smtp.eu.adacore.com ([127.0.0.1]) by localhost (smtp.eu.adacore.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id TJszly0LioMr; Mon, 11 Nov 2013 18:07:23 +0100 (CET) Received: from polaris.localnet (bon31-6-88-161-99-133.fbx.proxad.net [88.161.99.133]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.eu.adacore.com (Postfix) with ESMTPSA id 89DB126A0CDF; Mon, 11 Nov 2013 18:07:23 +0100 (CET) From: Eric Botcazou To: Richard Biener Cc: gcc-patches@gcc.gnu.org, Jason Merrill Subject: Re: [patch] Fix PR ada/35998 Date: Mon, 11 Nov 2013 18:06:23 +0100 Message-ID: <2198096.Vj9GxGMGzo@polaris> User-Agent: KMail/4.7.2 (Linux/3.1.10-1.29-desktop; KDE/4.7.2; x86_64; ; ) In-Reply-To: References: <1953979.BppAL6HeZv@polaris> MIME-Version: 1.0 > Due to the different interfaces of int_size_in_bytes and > simple_type_size_in_bits (and 'size' in add_byte_size_attribute being > unsigned and not [unsigned] HWI) it would be cleaner to > add an early return after the call to int_size_in_bytes if its > return value is -1 (and make sure the return value doesn't > overflow an unsigned int - likewise for simple_type_size_in_bits, > not sure why that case doesn't use int_size_in_bytes as well ...)? Both calls are present in the first version of the function, but I agree that the discrepancy looks strange. Revised version attached, tested {GCC,GDB} on x86_64-suse-linux. 2013-11-11 Eric Botcazou PR ada/35998 * dwarf2out.c (add_byte_size_attribute): Use int_size_in_bytes also for fields. Do not add the attribute if the size is negative. Index: dwarf2out.c =================================================================== --- dwarf2out.c (revision 204444) +++ dwarf2out.c (working copy) @@ -16319,11 +16319,13 @@ add_subscript_info (dw_die_ref type_die, } } +/* Add a DW_AT_byte_size attribute to DIE with TREE_NODE's size. */ + static void add_byte_size_attribute (dw_die_ref die, tree tree_node) { dw_die_ref decl_die; - unsigned size; + HOST_WIDE_INT size; switch (TREE_CODE (tree_node)) { @@ -16347,7 +16349,7 @@ add_byte_size_attribute (dw_die_ref die, generally given as the number of bytes normally allocated for an object of the *declared* type of the member itself. This is true even for bit-fields. */ - size = simple_type_size_in_bits (field_type (tree_node)) / BITS_PER_UNIT; + size = int_size_in_bytes (field_type (tree_node)); break; default: gcc_unreachable (); @@ -16356,8 +16358,9 @@ add_byte_size_attribute (dw_die_ref die, /* Note that `size' might be -1 when we get to this point. If it is, that indicates that the byte size of the entity in question is variable. We have no good way of expressing this fact in Dwarf at the present time, - so just let the -1 pass on through. */ - add_AT_unsigned (die, DW_AT_byte_size, size); + when location description was not used by the caller code instead. */ + if (size >= 0) + add_AT_unsigned (die, DW_AT_byte_size, size); } /* For a FIELD_DECL node which represents a bit-field, output an attribute