From e9c310521182c9359cf23fa9b0c5057b35e8b53f Mon Sep 17 00:00:00 2001 From: Jonathan Wakely Date: Fri, 12 Feb 2021 11:09:00 +0000 Subject: [PATCH] libstdc++: Only use dynamic_cast in tests when RTTI is enabled libstdc++-v3/ChangeLog: * testsuite/27_io/basic_istringstream/rdbuf/char/2832.cc: Use static_cast when RTTI is disabled. * testsuite/27_io/basic_istringstream/rdbuf/wchar_t/2832.cc: Likewise. * testsuite/27_io/basic_ostringstream/rdbuf/char/2832.cc: Likewise. * testsuite/27_io/basic_ostringstream/rdbuf/wchar_t/2832.cc: Likewise. * testsuite/27_io/basic_stringstream/str/char/2.cc: Likewise. * testsuite/27_io/basic_stringstream/str/wchar_t/2.cc: Likewise. --- .../27_io/basic_istringstream/rdbuf/char/2832.cc | 10 +++++++--- .../27_io/basic_istringstream/rdbuf/wchar_t/2832.cc | 10 +++++++--- .../27_io/basic_ostringstream/rdbuf/char/2832.cc | 10 +++++++--- .../27_io/basic_ostringstream/rdbuf/wchar_t/2832.cc | 10 +++++++--- .../testsuite/27_io/basic_stringstream/str/char/2.cc | 10 +++++++--- .../27_io/basic_stringstream/str/wchar_t/2.cc | 10 +++++++--- 6 files changed, 42 insertions(+), 18 deletions(-) diff --git a/libstdc++-v3/testsuite/27_io/basic_istringstream/rdbuf/char/2832.cc b/libstdc++-v3/testsuite/27_io/basic_istringstream/rdbuf/char/2832.cc index 00f732fee57..87677c50a13 100644 --- a/libstdc++-v3/testsuite/27_io/basic_istringstream/rdbuf/char/2832.cc +++ b/libstdc++-v3/testsuite/27_io/basic_istringstream/rdbuf/char/2832.cc @@ -22,8 +22,8 @@ #include #include -void -redirect_buffer(std::ios& stream, std::streambuf* new_buf) +void +redirect_buffer(std::ios& stream, std::streambuf* new_buf) { stream.rdbuf(new_buf); } std::streambuf* @@ -50,7 +50,7 @@ void test02() redirect_buffer(sstrm1, &sbuf); std::stringbuf* const buf2 = sstrm1.rdbuf(); std::streambuf* pbasebuf2 = active_buffer(sstrm1); - VERIFY( buf1 == buf2 ); + VERIFY( buf1 == buf2 ); VERIFY( pbasebuf1 != pbasebuf2 ); VERIFY( pbasebuf2 == pbasebuf0 ); @@ -58,7 +58,11 @@ void test02() VERIFY( sstrm1.str() != str01 ); VERIFY( sstrm1.str() == str00 ); // however, casting the active streambuf to a stringbuf shows what's up: +#if __cpp_rtti std::stringbuf* psbuf = dynamic_cast(pbasebuf2); +#else + std::stringbuf* psbuf = static_cast(pbasebuf2); +#endif str02 = psbuf->str(); VERIFY( str02 == str01 ); diff --git a/libstdc++-v3/testsuite/27_io/basic_istringstream/rdbuf/wchar_t/2832.cc b/libstdc++-v3/testsuite/27_io/basic_istringstream/rdbuf/wchar_t/2832.cc index b24ecc6619f..64475b5fc61 100644 --- a/libstdc++-v3/testsuite/27_io/basic_istringstream/rdbuf/wchar_t/2832.cc +++ b/libstdc++-v3/testsuite/27_io/basic_istringstream/rdbuf/wchar_t/2832.cc @@ -20,8 +20,8 @@ #include #include -void -redirect_buffer(std::wios& stream, std::wstreambuf* new_buf) +void +redirect_buffer(std::wios& stream, std::wstreambuf* new_buf) { stream.rdbuf(new_buf); } std::wstreambuf* @@ -48,7 +48,7 @@ void test02() redirect_buffer(sstrm1, &sbuf); std::wstringbuf* const buf2 = sstrm1.rdbuf(); std::wstreambuf* pbasebuf2 = active_buffer(sstrm1); - VERIFY( buf1 == buf2 ); + VERIFY( buf1 == buf2 ); VERIFY( pbasebuf1 != pbasebuf2 ); VERIFY( pbasebuf2 == pbasebuf0 ); @@ -56,7 +56,11 @@ void test02() VERIFY( sstrm1.str() != str01 ); VERIFY( sstrm1.str() == str00 ); // however, casting the active streambuf to a stringbuf shows what's up: +#if __cpp_rtti std::wstringbuf* psbuf = dynamic_cast(pbasebuf2); +#else + std::wstringbuf* psbuf = static_cast(pbasebuf2); +#endif str02 = psbuf->str(); VERIFY( str02 == str01 ); diff --git a/libstdc++-v3/testsuite/27_io/basic_ostringstream/rdbuf/char/2832.cc b/libstdc++-v3/testsuite/27_io/basic_ostringstream/rdbuf/char/2832.cc index 825aaf32cef..553edd6c243 100644 --- a/libstdc++-v3/testsuite/27_io/basic_ostringstream/rdbuf/char/2832.cc +++ b/libstdc++-v3/testsuite/27_io/basic_ostringstream/rdbuf/char/2832.cc @@ -22,8 +22,8 @@ #include #include -void -redirect_buffer(std::ios& stream, std::streambuf* new_buf) +void +redirect_buffer(std::ios& stream, std::streambuf* new_buf) { stream.rdbuf(new_buf); } std::streambuf* @@ -50,7 +50,7 @@ void test02() redirect_buffer(sstrm1, &sbuf); std::stringbuf* const buf2 = sstrm1.rdbuf(); std::streambuf* pbasebuf2 = active_buffer(sstrm1); - VERIFY( buf1 == buf2 ); + VERIFY( buf1 == buf2 ); VERIFY( pbasebuf1 != pbasebuf2 ); VERIFY( pbasebuf2 == pbasebuf0 ); @@ -58,7 +58,11 @@ void test02() VERIFY( sstrm1.str() != str01 ); VERIFY( sstrm1.str() == str00 ); // however, casting the active streambuf to a stringbuf shows what's up: +#if __cpp_rtti std::stringbuf* psbuf = dynamic_cast(pbasebuf2); +#else + std::stringbuf* psbuf = static_cast(pbasebuf2); +#endif str02 = psbuf->str(); VERIFY( str02 == str01 ); diff --git a/libstdc++-v3/testsuite/27_io/basic_ostringstream/rdbuf/wchar_t/2832.cc b/libstdc++-v3/testsuite/27_io/basic_ostringstream/rdbuf/wchar_t/2832.cc index 927ebc207f1..3a1b4e52761 100644 --- a/libstdc++-v3/testsuite/27_io/basic_ostringstream/rdbuf/wchar_t/2832.cc +++ b/libstdc++-v3/testsuite/27_io/basic_ostringstream/rdbuf/wchar_t/2832.cc @@ -20,8 +20,8 @@ #include #include -void -redirect_buffer(std::wios& stream, std::wstreambuf* new_buf) +void +redirect_buffer(std::wios& stream, std::wstreambuf* new_buf) { stream.rdbuf(new_buf); } std::wstreambuf* @@ -48,7 +48,7 @@ void test02() redirect_buffer(sstrm1, &sbuf); std::wstringbuf* const buf2 = sstrm1.rdbuf(); std::wstreambuf* pbasebuf2 = active_buffer(sstrm1); - VERIFY( buf1 == buf2 ); + VERIFY( buf1 == buf2 ); VERIFY( pbasebuf1 != pbasebuf2 ); VERIFY( pbasebuf2 == pbasebuf0 ); @@ -56,7 +56,11 @@ void test02() VERIFY( sstrm1.str() != str01 ); VERIFY( sstrm1.str() == str00 ); // however, casting the active streambuf to a stringbuf shows what's up: +#if __cpp_rtti std::wstringbuf* psbuf = dynamic_cast(pbasebuf2); +#else + std::wstringbuf* psbuf = static_cast(pbasebuf2); +#endif str02 = psbuf->str(); VERIFY( str02 == str01 ); diff --git a/libstdc++-v3/testsuite/27_io/basic_stringstream/str/char/2.cc b/libstdc++-v3/testsuite/27_io/basic_stringstream/str/char/2.cc index b8c0140fecf..60631df83b5 100644 --- a/libstdc++-v3/testsuite/27_io/basic_stringstream/str/char/2.cc +++ b/libstdc++-v3/testsuite/27_io/basic_stringstream/str/char/2.cc @@ -22,8 +22,8 @@ #include #include -void -redirect_buffer(std::ios& stream, std::streambuf* new_buf) +void +redirect_buffer(std::ios& stream, std::streambuf* new_buf) { stream.rdbuf(new_buf); } std::streambuf* @@ -50,7 +50,7 @@ void test02() redirect_buffer(sstrm1, &sbuf); std::stringbuf* const buf2 = sstrm1.rdbuf(); std::streambuf* pbasebuf2 = active_buffer(sstrm1); - VERIFY( buf1 == buf2 ); + VERIFY( buf1 == buf2 ); VERIFY( pbasebuf1 != pbasebuf2 ); VERIFY( pbasebuf2 == pbasebuf0 ); @@ -58,7 +58,11 @@ void test02() VERIFY( sstrm1.str() != str01 ); VERIFY( sstrm1.str() == str00 ); // however, casting the active streambuf to a stringbuf shows what's up: +#if __cpp_rtti std::stringbuf* psbuf = dynamic_cast(pbasebuf2); +#else + std::stringbuf* psbuf = static_cast(pbasebuf2); +#endif str02 = psbuf->str(); VERIFY( str02 == str01 ); diff --git a/libstdc++-v3/testsuite/27_io/basic_stringstream/str/wchar_t/2.cc b/libstdc++-v3/testsuite/27_io/basic_stringstream/str/wchar_t/2.cc index 4f5461ea1c9..4e008a60e63 100644 --- a/libstdc++-v3/testsuite/27_io/basic_stringstream/str/wchar_t/2.cc +++ b/libstdc++-v3/testsuite/27_io/basic_stringstream/str/wchar_t/2.cc @@ -20,8 +20,8 @@ #include #include -void -redirect_buffer(std::wios& stream, std::wstreambuf* new_buf) +void +redirect_buffer(std::wios& stream, std::wstreambuf* new_buf) { stream.rdbuf(new_buf); } std::wstreambuf* @@ -48,7 +48,7 @@ void test02() redirect_buffer(sstrm1, &sbuf); std::wstringbuf* const buf2 = sstrm1.rdbuf(); std::wstreambuf* pbasebuf2 = active_buffer(sstrm1); - VERIFY( buf1 == buf2 ); + VERIFY( buf1 == buf2 ); VERIFY( pbasebuf1 != pbasebuf2 ); VERIFY( pbasebuf2 == pbasebuf0 ); @@ -56,7 +56,11 @@ void test02() VERIFY( sstrm1.str() != str01 ); VERIFY( sstrm1.str() == str00 ); // however, casting the active streambuf to a stringbuf shows what's up: +#if __cpp_rtti std::wstringbuf* psbuf = dynamic_cast(pbasebuf2); +#else + std::wstringbuf* psbuf = static_cast(pbasebuf2); +#endif str02 = psbuf->str(); VERIFY( str02 == str01 ); -- 2.30.2