]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
pretty-print: add selftest coverage for numbered args
authorDavid Malcolm <dmalcolm@redhat.com>
Wed, 10 Jan 2024 13:33:47 +0000 (08:33 -0500)
committerDavid Malcolm <dmalcolm@redhat.com>
Wed, 10 Jan 2024 13:33:47 +0000 (08:33 -0500)
No functional change intended.

gcc/ChangeLog:
* pretty-print.cc (selftest::test_pp_format): Add selftest
coverage for numbered args.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
gcc/pretty-print.cc

index fd4c38ed3eb4dcd2457cf2991206f2898b3cc661..859ae2a273dbfa7d562a8b9615656b84a14cae02 100644 (file)
@@ -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.  */