libstdc++: Only use dynamic_cast in tests when RTTI is enabled
authorJonathan Wakely <jwakely@redhat.com>
Fri, 12 Feb 2021 11:09:00 +0000 (11:09 +0000)
committerJonathan Wakely <jwakely@redhat.com>
Fri, 12 Feb 2021 14:30:13 +0000 (14:30 +0000)
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.

libstdc++-v3/testsuite/27_io/basic_istringstream/rdbuf/char/2832.cc
libstdc++-v3/testsuite/27_io/basic_istringstream/rdbuf/wchar_t/2832.cc
libstdc++-v3/testsuite/27_io/basic_ostringstream/rdbuf/char/2832.cc
libstdc++-v3/testsuite/27_io/basic_ostringstream/rdbuf/wchar_t/2832.cc
libstdc++-v3/testsuite/27_io/basic_stringstream/str/char/2.cc
libstdc++-v3/testsuite/27_io/basic_stringstream/str/wchar_t/2.cc

index 00f732fee579da09f37aad64df7f5316f96ab490..87677c50a13dbd88ac07b2b7e6316257dbc0ff66 100644 (file)
@@ -22,8 +22,8 @@
 #include <sstream>
 #include <testsuite_hooks.h>
 
-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<std::stringbuf*>(pbasebuf2);
+#else
+  std::stringbuf* psbuf = static_cast<std::stringbuf*>(pbasebuf2);
+#endif
   str02 = psbuf->str();
   VERIFY( str02 == str01 );
 
index b24ecc6619f68cfaa4bd1c36c8c5208cd755cce2..64475b5fc61bb571ab04829c5f8ae03948c49100 100644 (file)
@@ -20,8 +20,8 @@
 #include <sstream>
 #include <testsuite_hooks.h>
 
-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<std::wstringbuf*>(pbasebuf2);
+#else
+  std::wstringbuf* psbuf = static_cast<std::wstringbuf*>(pbasebuf2);
+#endif
   str02 = psbuf->str();
   VERIFY( str02 == str01 );
 
index 825aaf32cef3208dcfbd8466aeb83032a658b4e6..553edd6c2432b19e11181ad6cb5fc0afd1080e07 100644 (file)
@@ -22,8 +22,8 @@
 #include <sstream>
 #include <testsuite_hooks.h>
 
-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<std::stringbuf*>(pbasebuf2);
+#else
+  std::stringbuf* psbuf = static_cast<std::stringbuf*>(pbasebuf2);
+#endif
   str02 = psbuf->str();
   VERIFY( str02 == str01 );
 
index 927ebc207f11ee4db66639b222438b0d83442828..3a1b4e5276123f0d6f3d0335397b49522bfbf201 100644 (file)
@@ -20,8 +20,8 @@
 #include <sstream>
 #include <testsuite_hooks.h>
 
-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<std::wstringbuf*>(pbasebuf2);
+#else
+  std::wstringbuf* psbuf = static_cast<std::wstringbuf*>(pbasebuf2);
+#endif
   str02 = psbuf->str();
   VERIFY( str02 == str01 );
 
index b8c0140fecf159f34f9b4c7953a77522794061cd..60631df83b5acf3e08aa8d7d60e2a0192eb7e0a4 100644 (file)
@@ -22,8 +22,8 @@
 #include <sstream>
 #include <testsuite_hooks.h>
 
-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<std::stringbuf*>(pbasebuf2);
+#else
+  std::stringbuf* psbuf = static_cast<std::stringbuf*>(pbasebuf2);
+#endif
   str02 = psbuf->str();
   VERIFY( str02 == str01 );
 
index 4f5461ea1c969a4f1e8ad4178a05ad21b07eb93d..4e008a60e63a0ab84fd36315041f26d3f295cfb6 100644 (file)
@@ -20,8 +20,8 @@
 #include <sstream>
 #include <testsuite_hooks.h>
 
-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<std::wstringbuf*>(pbasebuf2);
+#else
+  std::wstringbuf* psbuf = static_cast<std::wstringbuf*>(pbasebuf2);
+#endif
   str02 = psbuf->str();
   VERIFY( str02 == str01 );