From patchwork Wed Jan 10 13:41:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Malcolm X-Patchwork-Id: 186882 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2411:b0:101:2151:f287 with SMTP id m17csp796502dyi; Wed, 10 Jan 2024 05:42:12 -0800 (PST) X-Google-Smtp-Source: AGHT+IGApgZayXeITVAI7ed5rAan2iMHqAiRMVABSirjYmC49PxSK5798GTP07R1zw8jTucRFFbD X-Received: by 2002:a05:6808:14d3:b0:3bc:e27:3cdf with SMTP id f19-20020a05680814d300b003bc0e273cdfmr1011182oiw.75.1704894131844; Wed, 10 Jan 2024 05:42:11 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1704894131; cv=pass; d=google.com; s=arc-20160816; b=mmHuVCLRjaKHlbRTTdstyh5JmKNDr9EdMorNipPCmAm9tLN+aAw9mH32k/B4A6OsY6 EMGO8+zrs5wo3+dxB+OOf6/skb3YqETHmy+W3oMCzujKtklR4pKFw13ohKbeHni61JjE iNl3P+U0Lu/gnu68mm9S4np1ADF5Itd6dEuJcqxO2rg2OkkkNG+FgOL86SLZbiTti7cm umQ1kBEOXRptuIbh7qt0RnssKtwqNMrR1wLaE7R7stPbBsuxx7nMJ2pIXP/rJ88QMdw6 SLWqdgp8eS9c7mgeIYxajg0TtOTbWR7MiAQyDTVzykg1EcABuZq7pP0IMPKn/uA/i2nk 4Ekw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature :arc-filter:dmarc-filter:delivered-to; bh=vhED0WbtG8f2sjyHOGeICeiRvcByn6CV0NVArWOmdfo=; fh=NXemEfxTRbZtBxUkxR2ehQUaYlcDfMdzPkO8MChVQE4=; b=VEtGaUnwwsCMhOjvpw8WGmGywoTR/b/41pC6lGKpbZtQMWdgcvzi9q0IAZSEwXMcoD d0P49UGiqLqBUC26Nq32namxOBXKt/uR0z1k5WkdWI76FtMJoYdK0sJRRL66ZGj6HyUK xoO2DsUpyvOTpsOZpm1M7jZfuKDPJOpCfUEwjP125/8SCo+i59MJ0VJ4yG9H3Se2aafB /S9s+3N6oPGtIbiZsxub5DWgRjPS7jPfz2ImwGF79O7ZLWq8it1D0tbgWMWud3Mvsx2l GTchBliz+GfSz/S+bD97lmnAsEPdHjT7Q8LoWVN58SSQ+udwD87VO+7TEjAWMP3DXHVc 0dsw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=JyDmegVc; arc=pass (i=1); 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=redhat.com Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id f2-20020a05620a280200b00781cac14dfdsi4294211qkp.705.2024.01.10.05.42.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Jan 2024 05:42:11 -0800 (PST) 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=@redhat.com header.s=mimecast20190719 header.b=JyDmegVc; arc=pass (i=1); 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=redhat.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 864093857831 for ; Wed, 10 Jan 2024 13:42:11 +0000 (GMT) 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.133.124]) by sourceware.org (Postfix) with ESMTPS id C757F3858410 for ; Wed, 10 Jan 2024 13:41:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C757F3858410 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org C757F3858410 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704894071; cv=none; b=J0IYOEFUS6CwUpeMfoJdBUhcGOAlAlfDXb1+SzVxb0kbD4bGUa9ia++LetfzPguivNQQ4/c7srxNslHbpyNTtBDZLPRm0reUEi2lXUS5owXgfi7laxO1+zlL85vxEWx1EjRAz3Nm0iUcYJ0Nx4ko0iTVFxz+8XeFVw3mRSzokc8= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704894071; c=relaxed/simple; bh=J5nbeaepCYa8GKgRzbFPt01vScqkIaemCnGImYLQDK0=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=iVUZ89Ig5FkOuHvRDzjnYatmHNbLfpSUAUVRnx88x5eokiqJfLHq+wyQxMVOCaND8wOkmhl/Pmz9+DDYodFvH8iJmf+Jd6qxaE2A4V+o/PdNAVkMrdh/yBBH87uECyZCdGBP4OtWuRJ1imVjfmGMuEPHiFvKqCh1GQJJrkcfQ20= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1704894069; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=vhED0WbtG8f2sjyHOGeICeiRvcByn6CV0NVArWOmdfo=; b=JyDmegVckNgqSQWYku4sDE3UXvT6Fm4xkXCWmm06FKf98Ap7KoIuq3u+CTj/cHbw/kVky6 0X3jtIp297jKUEpLiw8F95gwPW6P4TR5XXwA32vGP0/MgV2/SdfdPc9beH2k0AKeiZ/K3r 9fkPiwB41V+A/UM5mcqA+XC5z2Ce/1o= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-384-eidlHue7MfCpcjfEeA0jnQ-1; Wed, 10 Jan 2024 08:41:08 -0500 X-MC-Unique: eidlHue7MfCpcjfEeA0jnQ-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B82BD3C0ED66 for ; Wed, 10 Jan 2024 13:41:07 +0000 (UTC) Received: from t14s.localdomain.com (unknown [10.22.17.251]) by smtp.corp.redhat.com (Postfix) with ESMTP id 924ED1121306; Wed, 10 Jan 2024 13:41:07 +0000 (UTC) From: David Malcolm To: gcc-patches@gcc.gnu.org Cc: David Malcolm Subject: [pushed 1/3] pretty-print: add selftest coverage for numbered args Date: Wed, 10 Jan 2024 08:41:03 -0500 Message-Id: <20240110134105.749310-1-dmalcolm@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.3 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.6 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_H3, 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.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1787711069196279177 X-GMAIL-MSGID: 1787711069196279177 No functional change intended. Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu. Pushed to trunk as r14-7104-g7daa935c7997f3. gcc/ChangeLog: * pretty-print.cc (selftest::test_pp_format): Add selftest coverage for numbered args. Signed-off-by: David Malcolm --- gcc/pretty-print.cc | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/gcc/pretty-print.cc b/gcc/pretty-print.cc index fd4c38ed3eb4..859ae2a273db 100644 --- a/gcc/pretty-print.cc +++ b/gcc/pretty-print.cc @@ -2605,6 +2605,20 @@ test_pp_format () assert_pp_format (SELFTEST_LOCATION, "item 3 of 7", "item %i of %i", 3, 7); assert_pp_format (SELFTEST_LOCATION, "problem with `bar' at line 10", "problem with %qs at line %i", "bar", 10); + + /* Verified numbered args. */ + assert_pp_format (SELFTEST_LOCATION, + "foo: second bar: first", + "foo: %2$s bar: %1$s", + "first", "second"); + assert_pp_format (SELFTEST_LOCATION, + "foo: 1066 bar: 1776", + "foo: %2$i bar: %1$i", + 1776, 1066); + assert_pp_format (SELFTEST_LOCATION, + "foo: second bar: 1776", + "foo: %2$s bar: %1$i", + 1776, "second"); } /* A subclass of pretty_printer for use by test_prefixes_and_wrapping. */