From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gateway20.websitewelcome.com (gateway20.websitewelcome.com [192.185.59.4]) by sourceware.org (Postfix) with ESMTPS id 0A91D3840C1E for ; Sat, 22 Aug 2020 21:07:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 0A91D3840C1E Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=tom@tromey.com Received: from cm13.websitewelcome.com (cm13.websitewelcome.com [100.42.49.6]) by gateway20.websitewelcome.com (Postfix) with ESMTP id 408C4400C63B2 for ; Sat, 22 Aug 2020 14:43:44 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id 9ajKkEWOuXp2A9ajKkVwZv; Sat, 22 Aug 2020 16:07:14 -0500 X-Authority-Reason: nr=8 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:MIME-Version :Content-Type:Content-Transfer-Encoding:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=9TU3cgSIm3AgUfqt6VTm2WmxrJMJ/Oe/XBqIkWzsGS8=; b=Sv6eyOLA2FViA6l9alW6eJIc0j uCPKiurqmBvKDKZCfN38HybafT7kMyZ9cZxsNGQvuhQC0c7WV/4ua1/yO2/ci9XJT5Pch6PcCUQvI zM0/Qxn82vIEnAKlZVQcyXfRO; Received: from 75-166-101-103.hlrn.qwest.net ([75.166.101.103]:51512 helo=bapiya.Home) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1k9ajK-003Uv2-2o; Sat, 22 Aug 2020 15:07:14 -0600 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH] Make range types inherit signed-ness from base type Date: Sat, 22 Aug 2020 15:07:11 -0600 Message-Id: <20200822210711.28361-1-tom@tromey.com> X-Mailer: git-send-email 2.17.2 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - box5379.bluehost.com X-AntiAbuse: Original Domain - sourceware.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tromey.com X-BWhitelist: no X-Source-IP: 75.166.101.103 X-Source-L: No X-Exim-ID: 1k9ajK-003Uv2-2o X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 75-166-101-103.hlrn.qwest.net (bapiya.Home) [75.166.101.103]:51512 X-Source-Auth: tom+tromey.com X-Email-Count: 1 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-3033.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, JMQ_SPF_NEUTRAL, RCVD_IN_ABUSEAT, RCVD_IN_BL_SPAMCOP_NET, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, SPF_NEUTRAL, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 22 Aug 2020 21:07:17 -0000 I ran across this comment in valprint.c: /* FIXME: create_static_range_type does not set the unsigned bit in a range type (I think it probably should copy it from the target type), so we won't print values which are too large to fit in a signed integer correctly. */ It seems to me that a range type ought to inherit its signed-ness from the underlying type, so this patch implements this change, and removes the comment. (It was also copied into m2-valprint.c.) I also remove the comment about handling ranges of enums, because I think that comment is incorrect. gdb/ChangeLog 2020-08-22 Tom Tromey * valprint.c (generic_value_print): Remove comment. * m2-valprint.c (m2_value_print_inner): Remove comment. * gdbtypes.c (create_range_type): Set TYPE_UNSIGNED from base type. --- gdb/ChangeLog | 7 +++++++ gdb/gdbtypes.c | 11 +---------- gdb/m2-valprint.c | 7 ------- gdb/valprint.c | 10 ---------- 4 files changed, 8 insertions(+), 27 deletions(-) diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c index c1eb03d8984..d96e91aee7d 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -944,16 +944,7 @@ create_range_type (struct type *result_type, struct type *index_type, result_type->set_bounds (bounds); - if (low_bound->kind () == PROP_CONST && low_bound->const_val () >= 0) - TYPE_UNSIGNED (result_type) = 1; - - /* Ada allows the declaration of range types whose upper bound is - less than the lower bound, so checking the lower bound is not - enough. Make sure we do not mark a range type whose upper bound - is negative as unsigned. */ - if (high_bound->kind () == PROP_CONST && high_bound->const_val () < 0) - TYPE_UNSIGNED (result_type) = 0; - + TYPE_UNSIGNED (result_type) = TYPE_UNSIGNED (index_type); TYPE_ENDIANITY_NOT_DEFAULT (result_type) = TYPE_ENDIANITY_NOT_DEFAULT (index_type); diff --git a/gdb/m2-valprint.c b/gdb/m2-valprint.c index b0a3ce3ec3e..0a67223f79a 100644 --- a/gdb/m2-valprint.c +++ b/gdb/m2-valprint.c @@ -448,13 +448,6 @@ m2_value_print_inner (struct value *val, struct ui_file *stream, int recurse, m2_value_print_inner (v, stream, recurse, options); break; } - /* FIXME: create_static_range_type does not set the unsigned bit in a - range type (I think it probably should copy it from the target - type), so we won't print values which are too large to - fit in a signed integer correctly. */ - /* FIXME: Doesn't handle ranges of enums correctly. (Can't just - print with the target type, though, because the size of our type - and the target type might differ). */ /* FALLTHROUGH */ case TYPE_CODE_REF: diff --git a/gdb/valprint.c b/gdb/valprint.c index db98ca2abc9..3ac23df5b12 100644 --- a/gdb/valprint.c +++ b/gdb/valprint.c @@ -869,16 +869,6 @@ generic_value_print (struct value *val, struct ui_file *stream, int recurse, break; case TYPE_CODE_RANGE: - /* FIXME: create_static_range_type does not set the unsigned bit in a - range type (I think it probably should copy it from the - target type), so we won't print values which are too large to - fit in a signed integer correctly. */ - /* FIXME: Doesn't handle ranges of enums correctly. (Can't just - print with the target type, though, because the size of our - type and the target type might differ). */ - - /* FALLTHROUGH */ - case TYPE_CODE_INT: generic_value_print_int (val, stream, options); break; -- 2.17.2