From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2181) id EB3AF3857801; Sat, 9 Oct 2021 00:15:01 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org EB3AF3857801 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="utf-8" From: Jonathan Wakely To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org Subject: [gcc r12-4261] libstdc++: Add missing _GLIBCXX_USE_WCHAR_T checks in testsuite X-Act-Checkin: gcc X-Git-Author: Jonathan Wakely X-Git-Refname: refs/heads/master X-Git-Oldrev: 29a9de9b40277af98515eabebb75be1f154e9505 X-Git-Newrev: 43e2a44182768ce1fe00d6ea41dcbad1f963d6c7 Message-Id: <20211009001501.EB3AF3857801@sourceware.org> Date: Sat, 9 Oct 2021 00:15:01 +0000 (GMT) X-BeenThere: libstdc++-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libstdc++-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 09 Oct 2021 00:15:02 -0000 https://gcc.gnu.org/g:43e2a44182768ce1fe00d6ea41dcbad1f963d6c7 commit r12-4261-g43e2a44182768ce1fe00d6ea41dcbad1f963d6c7 Author: Jonathan Wakely Date: Fri Oct 8 21:04:26 2021 +0100 libstdc++: Add missing _GLIBCXX_USE_WCHAR_T checks in testsuite These tests fail for a --disable-wchar_t build. libstdc++-v3/ChangeLog: * testsuite/22_locale/conversions/buffer/1.cc: Check _GLIBCXX_USE_WCHAR_T. * testsuite/22_locale/conversions/buffer/3.cc: Likewise. Add test using char16_t. * testsuite/22_locale/conversions/string/1.cc: Check _GLIBCXX_USE_WCHAR_T. * testsuite/27_io/filesystem/path/generic/generic_string.cc: Likewise. * testsuite/27_io/filesystem/path/modifiers/make_preferred.cc: Likewise. * testsuite/27_io/filesystem/path/native/alloc.cc: Likewise. * testsuite/27_io/filesystem/path/native/string-char8_t.cc: Likewise. * testsuite/27_io/filesystem/path/native/string.cc: Likewise. * testsuite/28_regex/algorithms/regex_match/extended/wstring_locale.cc: Likewise. * testsuite/experimental/filesystem/path/generic/generic_string.cc: Likewise. * testsuite/experimental/filesystem/path/native/alloc.cc: Likewise. * testsuite/experimental/filesystem/path/native/string-char8_t.cc: Likewise. * testsuite/experimental/filesystem/path/native/string.cc: Likewise. Diff: --- .../testsuite/22_locale/conversions/buffer/1.cc | 10 ++++++---- .../testsuite/22_locale/conversions/buffer/3.cc | 18 +++++++++++++++++- .../testsuite/22_locale/conversions/string/1.cc | 2 ++ .../27_io/filesystem/path/generic/generic_string.cc | 4 ++++ .../27_io/filesystem/path/modifiers/make_preferred.cc | 4 ++++ .../testsuite/27_io/filesystem/path/native/alloc.cc | 4 ++++ .../27_io/filesystem/path/native/string-char8_t.cc | 2 ++ .../testsuite/27_io/filesystem/path/native/string.cc | 2 ++ .../algorithms/regex_match/extended/wstring_locale.cc | 2 ++ .../filesystem/path/generic/generic_string.cc | 2 ++ .../experimental/filesystem/path/native/alloc.cc | 4 ++++ .../filesystem/path/native/string-char8_t.cc | 2 ++ .../experimental/filesystem/path/native/string.cc | 2 ++ 13 files changed, 53 insertions(+), 5 deletions(-) diff --git a/libstdc++-v3/testsuite/22_locale/conversions/buffer/1.cc b/libstdc++-v3/testsuite/22_locale/conversions/buffer/1.cc index 2d5c09449ca..9db7fce7241 100644 --- a/libstdc++-v3/testsuite/22_locale/conversions/buffer/1.cc +++ b/libstdc++-v3/testsuite/22_locale/conversions/buffer/1.cc @@ -31,12 +31,11 @@ template using buf_conv = std::wbuffer_convert, Elem>; using std::string; -using std::stringstream; using std::wstring; -using std::wstringstream; void test01() { +#ifdef _GLIBCXX_USE_WCHAR_T buf_conv buf; std::stringbuf sbuf; VERIFY( buf.rdbuf() == nullptr ); @@ -46,6 +45,7 @@ void test01() __gnu_test::implicitly_default_constructible test; test.operator()>(); // P0935R0 +#endif } void test02() @@ -53,7 +53,7 @@ void test02() std::stringbuf sbuf; buf_conv buf(&sbuf); // noconv - stringstream ss; + std::stringstream ss; ss.std::ios::rdbuf(&buf); string input = "King for a day..."; ss << input << std::flush; @@ -63,15 +63,17 @@ void test02() void test03() { +#ifdef _GLIBCXX_USE_WCHAR_T std::stringbuf sbuf; buf_conv buf(&sbuf); - wstringstream ss; + std::wstringstream ss; ss.std::wios::rdbuf(&buf); wstring input = L"Fool for a lifetime"; ss << input << std::flush; string output = sbuf.str(); VERIFY( output == "Fool for a lifetime" ); +#endif } int main() diff --git a/libstdc++-v3/testsuite/22_locale/conversions/buffer/3.cc b/libstdc++-v3/testsuite/22_locale/conversions/buffer/3.cc index 94aa43bbfdb..3e1d90ffe92 100644 --- a/libstdc++-v3/testsuite/22_locale/conversions/buffer/3.cc +++ b/libstdc++-v3/testsuite/22_locale/conversions/buffer/3.cc @@ -38,21 +38,37 @@ private: char c = 'a'; }; -struct codecvt : std::codecvt { }; void test01() { +#ifdef _GLIBCXX_USE_WCHAR_T + struct codecvt : std::codecvt { }; // https://gcc.gnu.org/ml/libstdc++/2017-11/msg00022.html streambuf sb; std::wbuffer_convert conv(&sb); VERIFY( sb.in_avail() == 0 ); wchar_t c = conv.sgetc(); VERIFY( c == L'a' ); +#endif +} + + +void +test02() +{ + struct codecvt : std::codecvt { }; + // https://gcc.gnu.org/ml/libstdc++/2017-11/msg00022.html + streambuf sb; + std::wbuffer_convert conv(&sb); + VERIFY( sb.in_avail() == 0 ); + char16_t c = conv.sgetc(); + VERIFY( c == u'a' ); } int main() { test01(); + test02(); } diff --git a/libstdc++-v3/testsuite/22_locale/conversions/string/1.cc b/libstdc++-v3/testsuite/22_locale/conversions/string/1.cc index 0016910441e..b5132dadce4 100644 --- a/libstdc++-v3/testsuite/22_locale/conversions/string/1.cc +++ b/libstdc++-v3/testsuite/22_locale/conversions/string/1.cc @@ -51,6 +51,7 @@ void test01() void test02() { +#ifdef _GLIBCXX_USE_WCHAR_T typedef str_conv wsc; wsc c; string input = "Fool for a lifetime"; @@ -71,6 +72,7 @@ void test02() __gnu_test::implicitly_default_constructible test; test.operator()(); // P0935R0 +#endif } int main() diff --git a/libstdc++-v3/testsuite/27_io/filesystem/path/generic/generic_string.cc b/libstdc++-v3/testsuite/27_io/filesystem/path/generic/generic_string.cc index 85d564e1592..4a603e23067 100644 --- a/libstdc++-v3/testsuite/27_io/filesystem/path/generic/generic_string.cc +++ b/libstdc++-v3/testsuite/27_io/filesystem/path/generic/generic_string.cc @@ -69,7 +69,9 @@ test03() // A path constructed from the generic format string should compare equal // to the original, because they represent the same path. VERIFY( path(p.generic_string()) == p ); +#ifdef _GLIBCXX_USE_WCHAR_T VERIFY( path(p.generic_wstring()) == p ); +#endif VERIFY( path(p.generic_u8string()) == p ); VERIFY( path(p.generic_u16string()) == p ); VERIFY( path(p.generic_u32string()) == p ); @@ -80,7 +82,9 @@ test03() // A path constructed from the generic format string should compare equal // to the original, because they represent the same path. VERIFY( path(p.generic_string()) == p ); +#ifdef _GLIBCXX_USE_WCHAR_T VERIFY( path(p.generic_wstring()) == p ); +#endif VERIFY( path(p.generic_u8string()) == p ); VERIFY( path(p.generic_u16string()) == p ); VERIFY( path(p.generic_u32string()) == p ); diff --git a/libstdc++-v3/testsuite/27_io/filesystem/path/modifiers/make_preferred.cc b/libstdc++-v3/testsuite/27_io/filesystem/path/modifiers/make_preferred.cc index 8f9e720f302..d21f1796798 100644 --- a/libstdc++-v3/testsuite/27_io/filesystem/path/modifiers/make_preferred.cc +++ b/libstdc++-v3/testsuite/27_io/filesystem/path/modifiers/make_preferred.cc @@ -45,7 +45,11 @@ struct checker { static void check() { +#ifdef _GLIBCXX_USE_WCHAR_T VERIFY( path("foo/bar").make_preferred() == L"foo\\bar" ); +#else + VERIFY( ! "filesystem::path needs --enable-wchar_t on this target" ); +#endif } }; diff --git a/libstdc++-v3/testsuite/27_io/filesystem/path/native/alloc.cc b/libstdc++-v3/testsuite/27_io/filesystem/path/native/alloc.cc index fb0b75d2efc..87a59b6735d 100644 --- a/libstdc++-v3/testsuite/27_io/filesystem/path/native/alloc.cc +++ b/libstdc++-v3/testsuite/27_io/filesystem/path/native/alloc.cc @@ -41,9 +41,11 @@ test01() VERIFY( str8.get_allocator() == alloc(1) ); #endif +#ifdef _GLIBCXX_USE_WCHAR_T auto strw = p.string(alloc(2)); VERIFY( strw == L"" ); VERIFY( strw.get_allocator() == alloc(2) ); +#endif auto str16 = p.string(alloc(3)); VERIFY( str16 == u"" ); @@ -70,9 +72,11 @@ test02() VERIFY( str8.get_allocator() == alloc(1) ); #endif +#ifdef _GLIBCXX_USE_WCHAR_T auto strw = p.string(alloc(2)); VERIFY( strw == L"abcdefghijklmnopqrstuvwxyz" ); VERIFY( strw.get_allocator() == alloc(2) ); +#endif auto str16 = p.string(alloc(3)); VERIFY( str16 == u"abcdefghijklmnopqrstuvwxyz" ); diff --git a/libstdc++-v3/testsuite/27_io/filesystem/path/native/string-char8_t.cc b/libstdc++-v3/testsuite/27_io/filesystem/path/native/string-char8_t.cc index df0bb5f0156..94421292d27 100644 --- a/libstdc++-v3/testsuite/27_io/filesystem/path/native/string-char8_t.cc +++ b/libstdc++-v3/testsuite/27_io/filesystem/path/native/string-char8_t.cc @@ -50,9 +50,11 @@ test02() VERIFY( str == "abc" ); VERIFY( str == p.string() ); +#ifdef _GLIBCXX_USE_WCHAR_T auto strw = p.string(); VERIFY( strw == L"abc" ); VERIFY( strw == p.wstring() ); +#endif #ifdef _GLIBCXX_USE_CHAR8_T auto str8 = p.string(); diff --git a/libstdc++-v3/testsuite/27_io/filesystem/path/native/string.cc b/libstdc++-v3/testsuite/27_io/filesystem/path/native/string.cc index b4f802d739f..a61f78ad0c4 100644 --- a/libstdc++-v3/testsuite/27_io/filesystem/path/native/string.cc +++ b/libstdc++-v3/testsuite/27_io/filesystem/path/native/string.cc @@ -48,9 +48,11 @@ test02() VERIFY( str == "abc" ); VERIFY( str == p.string() ); +#ifdef _GLIBCXX_USE_WCHAR_T auto strw = p.string(); VERIFY( strw == L"abc" ); VERIFY( strw == p.wstring() ); +#endif auto str16 = p.string(); VERIFY( str16 == u"abc" ); diff --git a/libstdc++-v3/testsuite/28_regex/algorithms/regex_match/extended/wstring_locale.cc b/libstdc++-v3/testsuite/28_regex/algorithms/regex_match/extended/wstring_locale.cc index bd030373e71..a24ee630797 100644 --- a/libstdc++-v3/testsuite/28_regex/algorithms/regex_match/extended/wstring_locale.cc +++ b/libstdc++-v3/testsuite/28_regex/algorithms/regex_match/extended/wstring_locale.cc @@ -35,12 +35,14 @@ using namespace std; void test01() { +#ifdef _GLIBCXX_USE_WCHAR_T std::wstring str2 = L"ÜBER"; std::wregex re2; re2.imbue(std::locale("de_DE.UTF-8")); re2.assign(L"[[:upper:]]*", std::regex::extended); std::wsmatch m2; VERIFY(regex_match_debug(str2, m2, re2)); +#endif } int diff --git a/libstdc++-v3/testsuite/experimental/filesystem/path/generic/generic_string.cc b/libstdc++-v3/testsuite/experimental/filesystem/path/generic/generic_string.cc index d8e35ee8707..26d68c81b96 100644 --- a/libstdc++-v3/testsuite/experimental/filesystem/path/generic/generic_string.cc +++ b/libstdc++-v3/testsuite/experimental/filesystem/path/generic/generic_string.cc @@ -55,7 +55,9 @@ test03() // A path constructed from the generic format string should compare equal // to the original, because they represent the same path. VERIFY( path(p.generic_string()) == p ); +#ifdef _GLIBCXX_USE_WCHAR_T VERIFY( path(p.generic_wstring()) == p ); +#endif VERIFY( path(p.generic_u8string()) == p ); VERIFY( path(p.generic_u16string()) == p ); VERIFY( path(p.generic_u32string()) == p ); diff --git a/libstdc++-v3/testsuite/experimental/filesystem/path/native/alloc.cc b/libstdc++-v3/testsuite/experimental/filesystem/path/native/alloc.cc index 591ebae263b..04426480311 100644 --- a/libstdc++-v3/testsuite/experimental/filesystem/path/native/alloc.cc +++ b/libstdc++-v3/testsuite/experimental/filesystem/path/native/alloc.cc @@ -43,9 +43,11 @@ test01() VERIFY( str8.get_allocator() == alloc(1) ); #endif +#ifdef _GLIBCXX_USE_WCHAR_T auto strw = p.string(alloc(2)); VERIFY( strw == L"" ); VERIFY( strw.get_allocator() == alloc(2) ); +#endif auto str16 = p.string(alloc(3)); VERIFY( str16 == u"" ); @@ -72,9 +74,11 @@ test02() VERIFY( str8.get_allocator() == alloc(1) ); #endif +#ifdef _GLIBCXX_USE_WCHAR_T auto strw = p.string(alloc(2)); VERIFY( strw == L"abcdefghijklmnopqrstuvwxyz" ); VERIFY( strw.get_allocator() == alloc(2) ); +#endif auto str16 = p.string(alloc(3)); VERIFY( str16 == u"abcdefghijklmnopqrstuvwxyz" ); diff --git a/libstdc++-v3/testsuite/experimental/filesystem/path/native/string-char8_t.cc b/libstdc++-v3/testsuite/experimental/filesystem/path/native/string-char8_t.cc index d8dc1f81e50..9775fe89518 100644 --- a/libstdc++-v3/testsuite/experimental/filesystem/path/native/string-char8_t.cc +++ b/libstdc++-v3/testsuite/experimental/filesystem/path/native/string-char8_t.cc @@ -50,9 +50,11 @@ test02() VERIFY( str == u"abc" ); VERIFY( str == p.string() ); +#ifdef _GLIBCXX_USE_WCHAR_T auto strw = p.string(); VERIFY( strw == L"abc" ); VERIFY( strw == p.wstring() ); +#endif #ifdef _GLIBCXX_USE_CHAR8_T auto str8 = p.string(); diff --git a/libstdc++-v3/testsuite/experimental/filesystem/path/native/string.cc b/libstdc++-v3/testsuite/experimental/filesystem/path/native/string.cc index 40f9bb9b4c3..d82a5390840 100644 --- a/libstdc++-v3/testsuite/experimental/filesystem/path/native/string.cc +++ b/libstdc++-v3/testsuite/experimental/filesystem/path/native/string.cc @@ -50,9 +50,11 @@ test02() VERIFY( str == u"abc" ); VERIFY( str == p.string() ); +#ifdef _GLIBCXX_USE_WCHAR_T auto strw = p.string(); VERIFY( strw == L"abc" ); VERIFY( strw == p.wstring() ); +#endif auto str16 = p.string(); VERIFY( str16 == u"abc" );