From patchwork Sat Oct 9 00:13:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jonathan Wakely X-Patchwork-Id: 46024 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 8B9EF3858006 for ; Sat, 9 Oct 2021 00:21:24 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8B9EF3858006 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1633738884; bh=2OYCPythQLYLf738DxnQyzbqaRtMb6gJ4xwrQDlUYiY=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=mOdJpZWrQppLtrm6Ck91ky3XCh6JzXqzhG+pubFn5+B6WfEvrJxeA2cG1u+ZmiVJI txvsYn/ROggp+0alhqFMXz+CDw7faZY5ahCHavtivq8/MZO9wqqukQumtIVNgYNZcC UHquy7WDC9DSzK7JE82xQ9unGJWgKF+qgxtoZrhw= 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 ESMTP id 359163857C6A for ; Sat, 9 Oct 2021 00:14:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 359163857C6A Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-562-N6YsAwW0O9yqmk2iNDnlFQ-1; Fri, 08 Oct 2021 20:13:53 -0400 X-MC-Unique: N6YsAwW0O9yqmk2iNDnlFQ-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A065D1006AA7; Sat, 9 Oct 2021 00:13:52 +0000 (UTC) Received: from localhost (unknown [10.33.37.44]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1B21860C0F; Sat, 9 Oct 2021 00:13:51 +0000 (UTC) To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [committed 1/8] libstdc++: Add missing _GLIBCXX_USE_WCHAR_T checks in testsuite Date: Sat, 9 Oct 2021 01:13:44 +0100 Message-Id: <20211009001351.659647-1-jwakely@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-14.5 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=unavailable autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Jonathan Wakely via Gcc-patches From: Jonathan Wakely Reply-To: Jonathan Wakely Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" These tests fail for a --disable-wchar_t build. Tested powerpc64le-linux and x86_64-linux, including a --disable-wchar_t build. Pushed to trunk. 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. --- .../22_locale/conversions/buffer/1.cc | 10 ++++++---- .../22_locale/conversions/buffer/3.cc | 18 +++++++++++++++++- .../22_locale/conversions/string/1.cc | 2 ++ .../filesystem/path/generic/generic_string.cc | 4 ++++ .../path/modifiers/make_preferred.cc | 4 ++++ .../27_io/filesystem/path/native/alloc.cc | 4 ++++ .../filesystem/path/native/string-char8_t.cc | 2 ++ .../27_io/filesystem/path/native/string.cc | 2 ++ .../regex_match/extended/wstring_locale.cc | 2 ++ .../filesystem/path/generic/generic_string.cc | 2 ++ .../filesystem/path/native/alloc.cc | 4 ++++ .../filesystem/path/native/string-char8_t.cc | 2 ++ .../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" );