From patchwork Tue Aug 1 00:35:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Palka X-Patchwork-Id: 1815305 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=O+IoBe6I; dkim-atps=neutral Received: from server2.sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4RFGP56yVRz1yfG for ; Tue, 1 Aug 2023 10:35:53 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 4BCA03857C55 for ; Tue, 1 Aug 2023 00:35:51 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4BCA03857C55 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1690850151; bh=ssLaMVzcmMPCz4dONoXl1f324f4A39BRC2ucfvUi3Is=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=O+IoBe6I3wBBihAi6JtL3B2jconmdB85BDocUrwe4UUl1HAbharbIJus08p3cKd3+ GulZDB3RefnkHIB5WrPdVxb49NTOejTM0OLqxNzN48a4ZTw6oyl6p+0oZDBZ7D7Sqb VD17OM8HsXe3QlZYXpyzvi1A7APuaW39BelYlhbs= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id E8C79385841C for ; Tue, 1 Aug 2023 00:35:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E8C79385841C Received: from mail-qv1-f71.google.com (mail-qv1-f71.google.com [209.85.219.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-461-Swz5XJ2aOk2U22FlG8n5Ag-1; Mon, 31 Jul 2023 20:35:08 -0400 X-MC-Unique: Swz5XJ2aOk2U22FlG8n5Ag-1 Received: by mail-qv1-f71.google.com with SMTP id 6a1803df08f44-63d41d1542dso57501936d6.0 for ; Mon, 31 Jul 2023 17:35:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690850108; x=1691454908; 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=ssLaMVzcmMPCz4dONoXl1f324f4A39BRC2ucfvUi3Is=; b=CaC+fsi7QqOC+qPjAiP/8pywcyiWJGIDIuhmqHPNI3LhEYwYUsBa9ZbpX6czFS+DAL z498HVdltci6cARolW7383l/LBl8OIPvtcy9iycyh3jeCOZqqz0fBPsrAzr99F/qR2fp DODMODQXh1CknHXdGd9+NId8yN5cj+jEzR3cOoqLZp3ceXYvNHUWUYO2fHkqNjP3Z83s Vk86A3T1tBn3lw7HF5k+IuXbZwXEGJe3BXfX5FrybrAjUViFVbFAiM3JmXZBv7z6jZQI RqaipVsg7IHoN3ieTPiWppDxgfHmp1bJNk+Hx79BklltTWV1D0/CAndHjRc4bG06ax9E wW3w== X-Gm-Message-State: ABy/qLachMYfVyq/6d05rpeDwetwJc+bLTFByIhNCW3M/H5tXA55jO5h Pmm1mORV7noSg6o/yu2EpCStbDS+QTkRUNgCHV0Y3W3v3E7lver4cJhPpUMstAaIFn2knY7+I8q +4POEsiplR/qftyqsxVggw9/OJgCmNl+Q3c7MjZ6UKbSwMoxtogiatWXYU+2OD7/qzgDhrjSYm2 k= X-Received: by 2002:a0c:f3c8:0:b0:635:ec47:bfa0 with SMTP id f8-20020a0cf3c8000000b00635ec47bfa0mr11657596qvm.49.1690850108001; Mon, 31 Jul 2023 17:35:08 -0700 (PDT) X-Google-Smtp-Source: APBJJlH04AOOOl07qKfXABiDDe4urAqJkh5EMSyeptjEGmkToXdnDo2GCUsuAHmJYBXCk1rpfHrtmQ== X-Received: by 2002:a0c:f3c8:0:b0:635:ec47:bfa0 with SMTP id f8-20020a0cf3c8000000b00635ec47bfa0mr11657581qvm.49.1690850107505; Mon, 31 Jul 2023 17:35:07 -0700 (PDT) Received: from localhost.localdomain (ool-457670bb.dyn.optonline.net. [69.118.112.187]) by smtp.gmail.com with ESMTPSA id i7-20020a0cab47000000b0063c71b62239sm4262800qvb.42.2023.07.31.17.35.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 Jul 2023 17:35:07 -0700 (PDT) To: gcc-patches@gcc.gnu.org Cc: jason@redhat.com, Patrick Palka Subject: [PATCH] tree-pretty-print: handle COMPONENT_REF with non-decl RHS Date: Mon, 31 Jul 2023 20:35:05 -0400 Message-ID: <20230801003505.994240-1-ppalka@redhat.com> X-Mailer: git-send-email 2.41.0.478.gee48e70a82 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-13.7 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, 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: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Patrick Palka via Gcc-patches From: Patrick Palka Reply-To: Patrick Palka Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" Tested on x86_64-pc-linux-gnu, does this look OK for trunk? -- >8 -- In the C++ front end, a COMPONENT_REF's second operand isn't always a decl (at least at template parse time). This patch makes the generic pretty printer not ICE when printing such a COMPONENT_REF. gcc/ChangeLog: * tree-pretty-print.cc (dump_generic_node) : Don't call component_ref_field_offset if the RHS isn't a decl. --- gcc/tree-pretty-print.cc | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/gcc/tree-pretty-print.cc b/gcc/tree-pretty-print.cc index 25d191b10fd..da8dd002a3b 100644 --- a/gcc/tree-pretty-print.cc +++ b/gcc/tree-pretty-print.cc @@ -2482,14 +2482,16 @@ dump_generic_node (pretty_printer *pp, tree node, int spc, dump_flags_t flags, if (op_prio (op0) < op_prio (node)) pp_right_paren (pp); pp_string (pp, str); - dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false); - op0 = component_ref_field_offset (node); - if (op0 && TREE_CODE (op0) != INTEGER_CST) - { - pp_string (pp, "{off: "); - dump_generic_node (pp, op0, spc, flags, false); + op1 = TREE_OPERAND (node, 1); + dump_generic_node (pp, op1, spc, flags, false); + if (DECL_P (op1)) + if (tree off = component_ref_field_offset (node)) + if (TREE_CODE (off) != INTEGER_CST) + { + pp_string (pp, "{off: "); + dump_generic_node (pp, off, spc, flags, false); pp_right_brace (pp); - } + } break; case BIT_FIELD_REF: