From patchwork Mon Sep 5 07:25:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Marc_Poulhi=C3=A8s?= X-Patchwork-Id: 962 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5044:0:0:0:0:0 with SMTP id h4csp56327wrt; Mon, 5 Sep 2022 00:27:25 -0700 (PDT) X-Google-Smtp-Source: AA6agR4Jlx8ycgImyUCEUCPs5IDRkRjf3hfvQCts2Si8AvLKXl8h/9Vm5wqCWQqBlA+xdRkzq5JF X-Received: by 2002:a05:6402:248a:b0:440:9709:df09 with SMTP id q10-20020a056402248a00b004409709df09mr42742179eda.42.1662362845562; Mon, 05 Sep 2022 00:27:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662362845; cv=none; d=google.com; s=arc-20160816; b=HLyK7V5Hx92dWKgNxwoS/lcyyY2mTSq7QoMWBsZxTe6MckA80zn1Dfme20RMFJMMLt hDv2gxk+lGKbRCspyQqjzNKMcWJytMQntr/zVlI49bV+Yi1yeMaCDQNgr95DNgL3toPn EgABze+tP33tL6OkolLmoyH83jUBBSXvqHDqK4zxG3GMmLsy618ldmHohaKPAXNqr3ZO 3ovf3NBwpLPTsA4Fpx0pRhVs8r6eyTa9sg9IHFREMDFswoh/Jayb1I4eP7R+S7ncLpFb NNUCTcidR5Suae15iaQmR9N4C6svgh8kDhydFd1fIWQoPZJ8tIOi6C6FWsX+IvaWZXSr yruQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:reply-to:from:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence :content-disposition:mime-version:message-id:subject:to:date :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=RAxt/ow37dSC2xZvrtt4t7/ylEOXyaAb9KE3hT0idwI=; b=Z81mThYQSKYZbRQ1KuFK638hM1Y284CnvKorEd/cbf61c6gKr6ShmDttYn7PVxHP3u U5dB/Fq4whm6oFN6xWZ4Joto7Cm4SAh625BZn3CHZqc8ftmmXSAQoJUBG8C9UCtjEyov ETnHKcXmzgTBbZxFcmgIObkMd9hed6oPz6qLNAWKiVpqcpjiBz4GKihKvE7tCtsrs9K6 L2nc53yIzyliuSE33Y+UiocIHnaYRkW6ulClmlUA4TxDB1tR7X9CX1WAwJfyjZftwC0p 2bz/7TK9/bGT5t2d5K4u2ay9WtSE4uQmpVgXantVaeFTOafiuNcfFky+cIyQbqhIMrSI eajA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=d7igvBHX; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id t21-20020aa7d715000000b0044ea16b9b43si504123edq.300.2022.09.05.00.27.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Sep 2022 00:27:25 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=d7igvBHX; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 1A36B385B837 for ; Mon, 5 Sep 2022 07:26:39 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1A36B385B837 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1662362799; bh=RAxt/ow37dSC2xZvrtt4t7/ylEOXyaAb9KE3hT0idwI=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=d7igvBHXOa5kdnc0M3k9AGfGa4i6f0bjy7KM1mxcDrSl4/gzW4mWZHEFrf6x0836n yeyNtXScy/1d3WYtfq0+HFaBe3p4/8Hn03J3VeqPXIpqCaHQpKJrV83AGEiwVJlyqi 6xlYkIHjLxuRCiSoMW0br0g88XuPjvzUdePdMUdg= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) by sourceware.org (Postfix) with ESMTPS id B93763858C50 for ; Mon, 5 Sep 2022 07:25:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org B93763858C50 Received: by mail-wr1-x42d.google.com with SMTP id n17so10088538wrm.4 for ; Mon, 05 Sep 2022 00:25:53 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date; bh=RAxt/ow37dSC2xZvrtt4t7/ylEOXyaAb9KE3hT0idwI=; b=bt7R+s5VW2smbZPFyiSkgNYyAht6q+F+UusC5HyPgH499O5GMmecBdhT3GN5Vsfj3P RgBma9Ujt+tCtIDApY769CpOC88N+SK00+a1Vfr6juM28jiA88TTSbqQ22aNbfESWrKz DlqzDwSTnklJKgR9xeIFO1T9uWwBPWRPC3a+ANfQ9m60e6lUnD3ghJIM090pmGdr9RJM LDq5ppRuvnSxmu6u0bKKTnygP640+zMec11df7q/3Aod3WAFyBAnuPjlOKJ7laf5Kq8F ujeXPyxzanmUgL5ARqByxUifih8N5jwgQz0dRYrbOSi5JzyBw1u5sxPzpX0dHRQHs0/Z 8LqA== X-Gm-Message-State: ACgBeo1NTyCyji3uMQjhwLiv2gpyv4ajhQN6/L/7oXpiLrVVTiw0rdS+ tDbJJy7oeR8fBhfnthMjr9QLzPKmlcOOkg== X-Received: by 2002:a5d:6d0f:0:b0:226:ef13:4689 with SMTP id e15-20020a5d6d0f000000b00226ef134689mr12116105wrq.203.1662362752487; Mon, 05 Sep 2022 00:25:52 -0700 (PDT) Received: from poulhies-Precision-5550 (static-176-191-105-132.ftth.abo.bbox.fr. [176.191.105.132]) by smtp.gmail.com with ESMTPSA id v64-20020a1cac43000000b003a844885f88sm10287043wme.22.2022.09.05.00.25.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Sep 2022 00:25:52 -0700 (PDT) Date: Mon, 5 Sep 2022 09:25:51 +0200 To: gcc-patches@gcc.gnu.org Subject: [Ada] Improve pretty-printing of iterated component associations Message-ID: <20220905072551.GA1174495@poulhies-Precision-5550> MIME-Version: 1.0 Content-Disposition: inline X-Spam-Status: No, score=-12.1 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: 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: =?utf-8?q?Marc_Poulhi=C3=A8s_via_Gcc-patches?= From: =?utf-8?q?Marc_Poulhi=C3=A8s?= Reply-To: Marc =?iso-8859-1?q?Poulhi=E8s?= Cc: Piotr Trojanek Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1743113783143852760?= X-GMAIL-MSGID: =?utf-8?q?1743113783143852760?= Pretty-printing used mostly in the debugger now handles more Ada 2022 syntax features. In particular, now it correctly handles expressions like "[for E of A when E /= X => E]". Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sprint.adb (Sprint_Node_Actual): Handle iterator_specification within iterated_component_association and iterator_filter within iterator_specification. diff --git a/gcc/ada/sprint.adb b/gcc/ada/sprint.adb --- a/gcc/ada/sprint.adb +++ b/gcc/ada/sprint.adb @@ -1341,9 +1341,13 @@ package body Sprint is when N_Iterated_Component_Association => Set_Debug_Sloc; Write_Str (" for "); - Write_Id (Defining_Identifier (Node)); - Write_Str (" in "); - Sprint_Bar_List (Discrete_Choices (Node)); + if Present (Iterator_Specification (Node)) then + Sprint_Node (Iterator_Specification (Node)); + else + Write_Id (Defining_Identifier (Node)); + Write_Str (" in "); + Sprint_Bar_List (Discrete_Choices (Node)); + end if; Write_Str (" => "); Sprint_Node (Expression (Node)); @@ -2307,6 +2311,11 @@ package body Sprint is Sprint_Node (Name (Node)); + if Present (Iterator_Filter (Node)) then + Write_Str (" when "); + Sprint_Node (Iterator_Filter (Node)); + end if; + when N_Itype_Reference => Write_Indent_Str_Sloc ("reference "); Write_Id (Itype (Node));