Blame SOURCES/0006-Don-t-assume-has_facet-codecvt_c16-when-run-against-.patch

e88ed2
From 59388ee3dac5c737086ed1f83f552a44481a2213 Mon Sep 17 00:00:00 2001
e88ed2
From: David Malcolm <dmalcolm@redhat.com>
e88ed2
Date: Tue, 31 Aug 2021 16:08:57 -0400
e88ed2
Subject: [PATCH 06/17] Don't assume has_facet<codecvt_c16> when run against
e88ed2
 system libstdc++
e88ed2
e88ed2
Upstream commit 2019-02-19:
e88ed2
  P0482R5 char8_t: Standard library support
e88ed2
    https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=c124af936b6b225eb548ccdd7f01400511d784dc
e88ed2
added new locale facets for char8_t.
e88ed2
e88ed2
has_facet<codecvt_c16> returns false, as it is using the std::locale the system libstdc++:
e88ed2
e88ed2
$ eu-readelf -s char16_t-char8_t.exe |c++filt |grep UNDEF|grep locale
e88ed2
    3: 0000000000000000      0 FUNC    GLOBAL DEFAULT    UNDEF std::locale::classic()@GLIBCXX_3.4 (2)
e88ed2
    8: 0000000000000000      0 FUNC    GLOBAL DEFAULT    UNDEF std::locale::locale(std::locale const&)@GLIBCXX_3.4 (2)
e88ed2
   13: 0000000000000000      0 FUNC    GLOBAL DEFAULT    UNDEF std::locale::id::_M_id() const@GLIBCXX_3.4 (2)
e88ed2
   22: 0000000000000000      0 FUNC    GLOBAL DEFAULT    UNDEF std::locale::~locale()@GLIBCXX_3.4 (2)
e88ed2
   64: 0000000000000000      0 FUNC    GLOBAL DEFAULT    UNDEF std::locale::classic()@@GLIBCXX_3.4
e88ed2
   76: 0000000000000000      0 FUNC    GLOBAL DEFAULT    UNDEF std::locale::locale(std::locale const&)@@GLIBCXX_3.4
e88ed2
   89: 0000000000000000      0 FUNC    GLOBAL DEFAULT    UNDEF std::locale::id::_M_id() const@@GLIBCXX_3.4
e88ed2
  108: 0000000000000000      0 FUNC    GLOBAL DEFAULT    UNDEF std::locale::~locale()@@GLIBCXX_3.4
e88ed2
e88ed2
Hence this patch tweaks tests so that they bail out if run against an older std::locale.
e88ed2
---
e88ed2
 libstdc++-v3/testsuite/22_locale/codecvt/char16_t-char8_t.cc | 3 ++-
e88ed2
 libstdc++-v3/testsuite/22_locale/codecvt/char16_t.cc         | 3 ++-
e88ed2
 libstdc++-v3/testsuite/22_locale/codecvt/char32_t-char8_t.cc | 3 ++-
e88ed2
 libstdc++-v3/testsuite/22_locale/codecvt/char32_t.cc         | 3 ++-
e88ed2
 libstdc++-v3/testsuite/22_locale/codecvt/utf8-char8_t.cc     | 2 ++
e88ed2
 libstdc++-v3/testsuite/22_locale/codecvt/utf8.cc             | 2 ++
e88ed2
 6 files changed, 12 insertions(+), 4 deletions(-)
e88ed2
e88ed2
diff --git a/libstdc++-v3/testsuite/22_locale/codecvt/char16_t-char8_t.cc b/libstdc++-v3/testsuite/22_locale/codecvt/char16_t-char8_t.cc
e88ed2
index 71a23bef4..d4aa519a2 100644
e88ed2
--- a/libstdc++-v3/testsuite/22_locale/codecvt/char16_t-char8_t.cc
e88ed2
+++ b/libstdc++-v3/testsuite/22_locale/codecvt/char16_t-char8_t.cc
e88ed2
@@ -31,7 +31,8 @@ test01()
e88ed2
   using namespace std;
e88ed2
   typedef codecvt<char16_t, char8_t, mbstate_t> codecvt_c16;
e88ed2
   locale loc_c = locale::classic();
e88ed2
-  VERIFY(has_facet<codecvt_c16>(loc_c));
e88ed2
+  if (!has_facet<codecvt_c16>(loc_c))
e88ed2
+    return;
e88ed2
   const codecvt_c16* const cvt = &use_facet<codecvt_c16>(loc_c);
e88ed2
 
e88ed2
   VERIFY(!cvt->always_noconv());
e88ed2
diff --git a/libstdc++-v3/testsuite/22_locale/codecvt/char16_t.cc b/libstdc++-v3/testsuite/22_locale/codecvt/char16_t.cc
e88ed2
index 7b5ce126d..05c77b2b1 100644
e88ed2
--- a/libstdc++-v3/testsuite/22_locale/codecvt/char16_t.cc
e88ed2
+++ b/libstdc++-v3/testsuite/22_locale/codecvt/char16_t.cc
e88ed2
@@ -29,7 +29,8 @@ test01()
e88ed2
   using namespace std;
e88ed2
   typedef codecvt<char16_t, char, mbstate_t> codecvt_c16;
e88ed2
   locale loc_c = locale::classic();
e88ed2
-  VERIFY(has_facet<codecvt_c16>(loc_c));
e88ed2
+  if (!has_facet<codecvt_c16>(loc_c))
e88ed2
+    return;
e88ed2
   const codecvt_c16* const cvt = &use_facet<codecvt_c16>(loc_c);
e88ed2
 
e88ed2
   VERIFY(!cvt->always_noconv());
e88ed2
diff --git a/libstdc++-v3/testsuite/22_locale/codecvt/char32_t-char8_t.cc b/libstdc++-v3/testsuite/22_locale/codecvt/char32_t-char8_t.cc
e88ed2
index f30ae22e9..281969e9b 100644
e88ed2
--- a/libstdc++-v3/testsuite/22_locale/codecvt/char32_t-char8_t.cc
e88ed2
+++ b/libstdc++-v3/testsuite/22_locale/codecvt/char32_t-char8_t.cc
e88ed2
@@ -33,7 +33,8 @@ test01()
e88ed2
   using namespace std;
e88ed2
   typedef codecvt<char32_t, char8_t, mbstate_t> codecvt_c32;
e88ed2
   locale loc_c = locale::classic();
e88ed2
-  VERIFY(has_facet<codecvt_c32>(loc_c));
e88ed2
+  if (!has_facet<codecvt_c32>(loc_c))
e88ed2
+    return;
e88ed2
   const codecvt_c32* const cvt = &use_facet<codecvt_c32>(loc_c);
e88ed2
 
e88ed2
   VERIFY(!cvt->always_noconv());
e88ed2
diff --git a/libstdc++-v3/testsuite/22_locale/codecvt/char32_t.cc b/libstdc++-v3/testsuite/22_locale/codecvt/char32_t.cc
e88ed2
index 558ba9145..82980b702 100644
e88ed2
--- a/libstdc++-v3/testsuite/22_locale/codecvt/char32_t.cc
e88ed2
+++ b/libstdc++-v3/testsuite/22_locale/codecvt/char32_t.cc
e88ed2
@@ -31,7 +31,8 @@ test01()
e88ed2
   using namespace std;
e88ed2
   typedef codecvt<char32_t, char, mbstate_t> codecvt_c32;
e88ed2
   locale loc_c = locale::classic();
e88ed2
-  VERIFY(has_facet<codecvt_c32>(loc_c));
e88ed2
+  if (!has_facet<codecvt_c32>(loc_c))
e88ed2
+    return;
e88ed2
   const codecvt_c32* const cvt = &use_facet<codecvt_c32>(loc_c);
e88ed2
 
e88ed2
   VERIFY(!cvt->always_noconv());
e88ed2
diff --git a/libstdc++-v3/testsuite/22_locale/codecvt/utf8-char8_t.cc b/libstdc++-v3/testsuite/22_locale/codecvt/utf8-char8_t.cc
e88ed2
index 5eab05ba2..d6f663ce6 100644
e88ed2
--- a/libstdc++-v3/testsuite/22_locale/codecvt/utf8-char8_t.cc
e88ed2
+++ b/libstdc++-v3/testsuite/22_locale/codecvt/utf8-char8_t.cc
e88ed2
@@ -34,6 +34,8 @@ void test(const C* from)
e88ed2
   std::mbstate_t state{};
e88ed2
   char8_t buf[16] = { };
e88ed2
   using test_type = std::codecvt<C, char8_t, std::mbstate_t>;
e88ed2
+  if (!std::has_facet<test_type>(std::locale::classic()))
e88ed2
+    return;
e88ed2
   const test_type& cvt = std::use_facet<test_type>(std::locale::classic());
e88ed2
   auto from_end = from + len;
e88ed2
   auto from_next = from;
e88ed2
diff --git a/libstdc++-v3/testsuite/22_locale/codecvt/utf8.cc b/libstdc++-v3/testsuite/22_locale/codecvt/utf8.cc
e88ed2
index b1b3cff31..167bc0ca3 100644
e88ed2
--- a/libstdc++-v3/testsuite/22_locale/codecvt/utf8.cc
e88ed2
+++ b/libstdc++-v3/testsuite/22_locale/codecvt/utf8.cc
e88ed2
@@ -32,6 +32,8 @@ void test(const C* from)
e88ed2
   std::mbstate_t state{};
e88ed2
   char buf[16] = { };
e88ed2
   using test_type = std::codecvt<C, char, std::mbstate_t>;
e88ed2
+  if (!std::has_facet<test_type>(std::locale::classic()))
e88ed2
+    return;
e88ed2
   const test_type& cvt = std::use_facet<test_type>(std::locale::classic());
e88ed2
   auto from_end = from + len;
e88ed2
   auto from_next = from;
e88ed2
-- 
e88ed2
2.31.1
e88ed2