With -maix32 (the default) we only have 16-bit wchar_t so these tests
fail. The debug.cc one is because we use -fwide-exec-charset=UTF-32BE
which tries to encode each wide character as four bytes in a 2-byte
wchar_t. The format.cc one is because the clown face character can't be
encoded in a single 16-bit wchar_t.

libstdc++-v3/ChangeLog:

        * testsuite/std/format/debug.cc: Disable for targets with 16-bit
        wchar_t.
        * testsuite/std/format/functions/format.cc: Use -DUNICODE for
        targets with 32-bit wchar_t.
        (test_unicode) [UNICODE]: Only run checks when UNICODE is
        defined.
---

Tested x86_64-linux and powerpc-aix.
Pushed to trunk.

 libstdc++-v3/testsuite/std/format/debug.cc            | 1 +
 libstdc++-v3/testsuite/std/format/functions/format.cc | 3 +++
 2 files changed, 4 insertions(+)

diff --git a/libstdc++-v3/testsuite/std/format/debug.cc 
b/libstdc++-v3/testsuite/std/format/debug.cc
index 6165a2954963..965b4dfbebc5 100644
--- a/libstdc++-v3/testsuite/std/format/debug.cc
+++ b/libstdc++-v3/testsuite/std/format/debug.cc
@@ -1,6 +1,7 @@
 // { dg-options "-fexec-charset=UTF-8 -fwide-exec-charset=UTF-32LE 
-DUNICODE_ENC" { target le } }
 // { dg-options "-fexec-charset=UTF-8 -fwide-exec-charset=UTF-32BE 
-DUNICODE_ENC" { target be } }
 // { dg-do run { target c++23 } }
+// { dg-require-effective-target 4byte_wchar_t }
 // { dg-add-options no_pch }
 // { dg-timeout-factor 2 }
 
diff --git a/libstdc++-v3/testsuite/std/format/functions/format.cc 
b/libstdc++-v3/testsuite/std/format/functions/format.cc
index 93c33b456e64..e4adf3aeb706 100644
--- a/libstdc++-v3/testsuite/std/format/functions/format.cc
+++ b/libstdc++-v3/testsuite/std/format/functions/format.cc
@@ -1,6 +1,7 @@
 // { dg-options "-fexec-charset=UTF-8" }
 // { dg-do run { target c++20 } }
 // { dg-add-options no_pch }
+// { dg-additional-options "-DUNICODE" { target 4byte_wchar_t } }
 
 #include <format>
 
@@ -511,6 +512,7 @@ test_bool()
 void
 test_unicode()
 {
+#ifdef UNICODE
   // Similar to sC example in test_std_examples, but not from the standard.
   // Verify that the character "🤡" has estimated field width 2,
   // rather than estimated field width equal to strlen("🤡"), which would be 
4,
@@ -564,6 +566,7 @@ test_unicode()
     std::string sA = std::format("{:>5}", input[0]);
     VERIFY( sA == input[1] );
   }
+#endif
 }
 
 int main()
-- 
2.49.0

Reply via email to