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: 83744 Return-Path: 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 1354D3857C75 for ; Wed, 10 Jan 2024 13:41:53 +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+patchwork=sourceware.org@gcc.gnu.org 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. */