Message ID | 20230427193515.1060101-1-tromey@adacore.com |
---|---|
State | New |
Headers |
Return-Path: <gdb-patches-bounces+patchwork=sourceware.org@sourceware.org> X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id BED7C3858416 for <patchwork@sourceware.org>; Thu, 27 Apr 2023 19:35:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BED7C3858416 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1682624150; bh=9XXShzMcRfYihkesaHQeOVaXmNYlOwuvJip4K50xonc=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=wra2qM1Uuiw0V2KeNWqoz05jzg+p975MoxLtodyvF6FeL7POZXQuE7ZXUU9MMZ1JQ qmEfOycFiqOmiuR3R8aIZoimiJnTJ7n6S8iG6+8mKqOw038QtC/8VOkHJMSTJb5Wh1 o1oAJ8kGsKrbPB76iZRZqRzPxKltHIOqIVBtwpgQ= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mail-il1-x12d.google.com (mail-il1-x12d.google.com [IPv6:2607:f8b0:4864:20::12d]) by sourceware.org (Postfix) with ESMTPS id 3F64C3858D37 for <gdb-patches@sourceware.org>; Thu, 27 Apr 2023 19:35:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 3F64C3858D37 Received: by mail-il1-x12d.google.com with SMTP id e9e14a558f8ab-32b437f4607so23364025ab.1 for <gdb-patches@sourceware.org>; Thu, 27 Apr 2023 12:35:27 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682624126; x=1685216126; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=9XXShzMcRfYihkesaHQeOVaXmNYlOwuvJip4K50xonc=; b=T2VsbdF+ey2sWczhYdwl26Q3dTxKHMSOf3bji+I13WwVOgPyxV/fdhpSqHggbKHiRJ KCXO+EZaBbebZrwpKy1j5jsdVT0CKMheetXyn3BnNHcB2/WnaN49Ja0E6Oq/EMOhwx3d PrtiFTVsLEjjgrmmek5vD+qZiz6ADA4B+qmKitf40+N16Idw23ofmE98aahulG88/Vob MKWn6OG6JF2QUi091ThNqW9npqJzbEMGmJYEEAhF6TnYxRzS4ykx0wVRSGuvPAPBvThC She2M7qwk/Wc8vXlRGGCuoFU7zhkRrvE36cvFIQ14qAFxkx6xYk1CkhOwQI6VBer8Ay5 m1oQ== X-Gm-Message-State: AC+VfDxWQg3GdNiheySXSBUlcG1YtRlScv5rZrfkp8Z1ToQECwEkmyAl 5cToi/MMPvaiRZIAipo5duB4GscpRMKV9+hWueqd7A== X-Google-Smtp-Source: ACHHUZ6/puHNgWl2fM2/u/f0suklOD/SSRV5mcGAEIcd7rmsXpXZ8tLb1nj/9EASj577ohfxT6WbeQ== X-Received: by 2002:a05:6e02:5cd:b0:325:b96e:6701 with SMTP id l13-20020a056e0205cd00b00325b96e6701mr2229807ils.2.1682624126426; Thu, 27 Apr 2023 12:35:26 -0700 (PDT) Received: from localhost.localdomain (71-211-191-82.hlrn.qwest.net. [71.211.191.82]) by smtp.gmail.com with ESMTPSA id v5-20020a927a05000000b003261b6acc8asm5009338ilc.79.2023.04.27.12.35.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Apr 2023 12:35:25 -0700 (PDT) To: gdb-patches@sourceware.org Cc: Tom Tromey <tromey@adacore.com> Subject: [PATCH] Do not change type in get_discrete_low_bound Date: Thu, 27 Apr 2023 13:35:15 -0600 Message-Id: <20230427193515.1060101-1-tromey@adacore.com> X-Mailer: git-send-email 2.39.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-11.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list <gdb-patches.sourceware.org> List-Unsubscribe: <https://sourceware.org/mailman/options/gdb-patches>, <mailto:gdb-patches-request@sourceware.org?subject=unsubscribe> List-Archive: <https://sourceware.org/pipermail/gdb-patches/> List-Post: <mailto:gdb-patches@sourceware.org> List-Help: <mailto:gdb-patches-request@sourceware.org?subject=help> List-Subscribe: <https://sourceware.org/mailman/listinfo/gdb-patches>, <mailto:gdb-patches-request@sourceware.org?subject=subscribe> From: Tom Tromey via Gdb-patches <gdb-patches@sourceware.org> Reply-To: Tom Tromey <tromey@adacore.com> Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" <gdb-patches-bounces+patchwork=sourceware.org@sourceware.org> |
Series |
Do not change type in get_discrete_low_bound
|
|
Commit Message
Tom Tromey
April 27, 2023, 7:35 p.m. UTC
get_discrete_low_bound has this code: /* Set unsigned indicator if warranted. */ if (low >= 0) type->set_is_unsigned (true); It's bad to modify a type in a getter like this, so this patch removes this code. FWIW I looked and this code has been there since at least 1999 (it was in the initial sourceware import). Types in general would benefit from const-ification, which would probably reveal more code like this, but I haven't attempted that. Regression tested on x86-64 Fedora 36. --- gdb/gdbtypes.c | 4 ---- 1 file changed, 4 deletions(-)
Comments
On Thu, 27 Apr 2023 13:35:15 -0600 Tom Tromey via Gdb-patches <gdb-patches@sourceware.org> wrote: > get_discrete_low_bound has this code: > > /* Set unsigned indicator if warranted. */ > if (low >= 0) > type->set_is_unsigned (true); > > It's bad to modify a type in a getter like this, so this patch removes > this code. FWIW I looked and this code has been there since at least > 1999 (it was in the initial sourceware import). LGTM. Reviewed-by: Kevin Buettner <kevinb@redhat.com>
diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c index 6af59351b76..c8d5314bce7 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -1084,10 +1084,6 @@ get_discrete_low_bound (struct type *type) low = type->field (i).loc_enumval (); } - /* Set unsigned indicator if warranted. */ - if (low >= 0) - type->set_is_unsigned (true); - return low; } else