Define cxx11-abi effective target for libstdc++ tests
authorJonathan Wakely <jwakely@redhat.com>
Fri, 13 Jan 2017 14:57:33 +0000 (14:57 +0000)
committerJonathan Wakely <redi@gcc.gnu.org>
Fri, 13 Jan 2017 14:57:33 +0000 (14:57 +0000)
PR libstdc++/79075
* testsuite/lib/libstdc++.exp (check_v3_target_filesystem_ts): Remove
redundant option from cxxflags.
(check_effective_target_cxx11-abi): Define.
* testsuite/21_strings/basic_string/allocator/71964.cc: Use cxx11-abi
effective target.
* testsuite/21_strings/basic_string/allocator/char/copy.cc: Likewise.
* testsuite/21_strings/basic_string/allocator/char/copy_assign.cc:
Likewise.
* testsuite/21_strings/basic_string/allocator/char/minimal.cc:
Likewise.
* testsuite/21_strings/basic_string/allocator/char/move.cc: Likewise.
* testsuite/21_strings/basic_string/allocator/char/move_assign.cc:
Likewise.
* testsuite/21_strings/basic_string/allocator/char/noexcept.cc:
Likewise.
* testsuite/21_strings/basic_string/allocator/char/swap.cc: Likewise.
* testsuite/21_strings/basic_string/allocator/wchar_t/copy.cc:
Likewise.
* testsuite/21_strings/basic_string/allocator/wchar_t/copy_assign.cc:
Likewise.
* testsuite/21_strings/basic_string/allocator/wchar_t/minimal.cc:
Likewise.
* testsuite/21_strings/basic_string/allocator/wchar_t/move.cc:
Likewise.
* testsuite/21_strings/basic_string/allocator/wchar_t/move_assign.cc:
Likewise.
* testsuite/21_strings/basic_string/allocator/wchar_t/noexcept.cc:
Likewise.
* testsuite/21_strings/basic_string/allocator/wchar_t/swap.cc:
Likewise.
* testsuite/23_containers/list/61347.cc: Likewise.
* testsuite/27_io/basic_fstream/cons/base.cc: Likewise.
* testsuite/27_io/ios_base/failure/cxx11.cc: Likewise.

From-SVN: r244440

20 files changed:
libstdc++-v3/ChangeLog
libstdc++-v3/testsuite/21_strings/basic_string/allocator/71964.cc
libstdc++-v3/testsuite/21_strings/basic_string/allocator/char/copy.cc
libstdc++-v3/testsuite/21_strings/basic_string/allocator/char/copy_assign.cc
libstdc++-v3/testsuite/21_strings/basic_string/allocator/char/minimal.cc
libstdc++-v3/testsuite/21_strings/basic_string/allocator/char/move.cc
libstdc++-v3/testsuite/21_strings/basic_string/allocator/char/move_assign.cc
libstdc++-v3/testsuite/21_strings/basic_string/allocator/char/noexcept.cc
libstdc++-v3/testsuite/21_strings/basic_string/allocator/char/swap.cc
libstdc++-v3/testsuite/21_strings/basic_string/allocator/wchar_t/copy.cc
libstdc++-v3/testsuite/21_strings/basic_string/allocator/wchar_t/copy_assign.cc
libstdc++-v3/testsuite/21_strings/basic_string/allocator/wchar_t/minimal.cc
libstdc++-v3/testsuite/21_strings/basic_string/allocator/wchar_t/move.cc
libstdc++-v3/testsuite/21_strings/basic_string/allocator/wchar_t/move_assign.cc
libstdc++-v3/testsuite/21_strings/basic_string/allocator/wchar_t/noexcept.cc
libstdc++-v3/testsuite/21_strings/basic_string/allocator/wchar_t/swap.cc
libstdc++-v3/testsuite/23_containers/list/61347.cc
libstdc++-v3/testsuite/27_io/basic_fstream/cons/base.cc
libstdc++-v3/testsuite/27_io/ios_base/failure/cxx11.cc
libstdc++-v3/testsuite/lib/libstdc++.exp

index 76d86fbf705d6e6b4e7651d95eedd4b98e72f380..a52fc9616196330dbcc293e0e1a5bcc2ac08ccb3 100644 (file)
@@ -1,3 +1,40 @@
+2017-01-13  Jonathan Wakely  <jwakely@redhat.com>
+
+       PR libstdc++/79075
+       * testsuite/lib/libstdc++.exp (check_v3_target_filesystem_ts): Remove
+       redundant option from cxxflags.
+       (check_effective_target_cxx11-abi): Define.
+       * testsuite/21_strings/basic_string/allocator/71964.cc: Use cxx11-abi
+       effective target.
+       * testsuite/21_strings/basic_string/allocator/char/copy.cc: Likewise.
+       * testsuite/21_strings/basic_string/allocator/char/copy_assign.cc:
+       Likewise.
+       * testsuite/21_strings/basic_string/allocator/char/minimal.cc:
+       Likewise.
+       * testsuite/21_strings/basic_string/allocator/char/move.cc: Likewise.
+       * testsuite/21_strings/basic_string/allocator/char/move_assign.cc:
+       Likewise.
+       * testsuite/21_strings/basic_string/allocator/char/noexcept.cc:
+       Likewise.
+       * testsuite/21_strings/basic_string/allocator/char/swap.cc: Likewise.
+       * testsuite/21_strings/basic_string/allocator/wchar_t/copy.cc:
+       Likewise.
+       * testsuite/21_strings/basic_string/allocator/wchar_t/copy_assign.cc:
+       Likewise.
+       * testsuite/21_strings/basic_string/allocator/wchar_t/minimal.cc:
+       Likewise.
+       * testsuite/21_strings/basic_string/allocator/wchar_t/move.cc:
+       Likewise.
+       * testsuite/21_strings/basic_string/allocator/wchar_t/move_assign.cc:
+       Likewise.
+       * testsuite/21_strings/basic_string/allocator/wchar_t/noexcept.cc:
+       Likewise.
+       * testsuite/21_strings/basic_string/allocator/wchar_t/swap.cc:
+       Likewise.
+       * testsuite/23_containers/list/61347.cc: Likewise.
+       * testsuite/27_io/basic_fstream/cons/base.cc: Likewise.
+       * testsuite/27_io/ios_base/failure/cxx11.cc: Likewise.
+
 2017-01-13  Ville Voutilainen  <ville.voutilainen@gmail.com>
 
        PR libstdc++/78389
index f5ef176cdfd8ab7a4ac8cc06acd75361d6eac8eb..70e5cf88dc9e2fa8bdcc85224cc3f64761a6364c 100644 (file)
@@ -16,6 +16,8 @@
 // <http://www.gnu.org/licenses/>.
 
 // { dg-do run { target c++11 } }
+// COW strings don't support C++11 allocators:
+// { dg-require-effective-target cxx11-abi }
 
 #include <string>
 #include <testsuite_hooks.h>
@@ -58,13 +60,10 @@ operator!=(const mv_allocator<T>&, const mv_allocator<U>&) { return false; }
 void
 test01()
 {
-  // COW strings don't support C++11 allocators
-#if _GLIBCXX_USE_CXX11_ABI
   std::basic_string<char, std::char_traits<char>, mv_allocator<char>> s;
   auto t = std::move(s);
   VERIFY( s.get_allocator().moved_from );
   VERIFY( t.get_allocator().moved_to );
-#endif
 }
 
 int
index 0e5f167f153f0d4e28a58a613f902df65e92290f..bdcadaf1e02a458c2d3d5e4a0c82560b2677c674 100644 (file)
 // <http://www.gnu.org/licenses/>.
 
 // { dg-do run { target c++11 } }
+// COW strings don't support C++11 allocators:
+// { dg-require-effective-target cxx11-abi }
 
 #include <string>
 #include <testsuite_hooks.h>
 #include <testsuite_allocator.h>
  
-#if _GLIBCXX_USE_CXX11_ABI
 using C = char;
 const C c = 'a';
 using traits = std::char_traits<C>;
@@ -86,9 +87,3 @@ int main()
   test03();
   return 0;
 }
-#else
-int main()
-{
-  // COW strings don't support C++11 allocators
-}
-#endif
index 5b9a0b0507ca19ee2a90cb6c5eda0cc0bf59b0e7..32ee708f3c6671a3ab5f9378871c7543f560b767 100644 (file)
 // <http://www.gnu.org/licenses/>.
 
 // { dg-do run { target c++11 } }
+// COW strings don't support C++11 allocators:
+// { dg-require-effective-target cxx11-abi }
 
 #include <string>
 #include <testsuite_hooks.h>
 #include <testsuite_allocator.h>
  
-#if _GLIBCXX_USE_CXX11_ABI
 using C = char;
 const C c = 'a';
 using traits = std::char_traits<C>;
@@ -104,9 +105,3 @@ int main()
   test02();
   return 0;
 }
-#else
-int main()
-{
-  // COW strings don't support C++11 allocators
-}
-#endif
index 6f0aeb5933571819f6beb6c0d6faf0f10757fa07..46b4215bcf2c7e8d64d9c7bedc4e72ec89712486 100644 (file)
 // <http://www.gnu.org/licenses/>.
 
 // { dg-do run { target c++11 } }
+// COW strings don't support C++11 allocators:
+// { dg-require-effective-target cxx11-abi }
 
 #include <string>
 #include <memory>
 #include <testsuite_hooks.h>
 #include <testsuite_allocator.h>
  
-#if _GLIBCXX_USE_CXX11_ABI
 using C = char;
 const C c = 'a';
 using traits = std::char_traits<C>;
@@ -40,9 +41,6 @@ void test01()
   v.assign(1, c);
   v.assign(100, c);
 }
-#else
-void test01() { }
-#endif
 
 int main()
 {
index 4e45a053c518ee26a311ca47c59b717292d8f18c..820b3ed479103d743bb429c3d90bb7f76f8baaa2 100644 (file)
 // <http://www.gnu.org/licenses/>.
 
 // { dg-do run { target c++11 } }
+// COW strings don't support C++11 allocators:
+// { dg-require-effective-target cxx11-abi }
 
 #include <string>
 #include <testsuite_hooks.h>
 #include <testsuite_allocator.h>
 
-#if _GLIBCXX_USE_CXX11_ABI
 using C = char;
 const C c = 'a';
 using traits = std::char_traits<C>;
@@ -56,9 +57,3 @@ int main()
   test02();
   return 0;
 }
-#else
-int main()
-{
-  // COW strings don't support C++11 allocators
-}
-#endif
index 0151a29d5f01167b8ccab51340b45c328f2aaf6a..df85a0b2861c1241363e7385c6bcbb187cf17d0b 100644 (file)
 // <http://www.gnu.org/licenses/>.
 
 // { dg-do run { target c++11 } }
+// COW strings don't support C++11 allocators:
+// { dg-require-effective-target cxx11-abi }
 
 #include <string>
 #include <testsuite_hooks.h>
 #include <testsuite_allocator.h>
  
-#if _GLIBCXX_USE_CXX11_ABI
 using C = char;
 const C c = 'a';
 using traits = std::char_traits<C>;
@@ -149,9 +150,3 @@ int main()
   test03();
   return 0;
 }
-#else
-int main()
-{
-  // COW strings don't support C++11 allocators
-}
-#endif
index b7917e0114398b5d03fedf9fbeab79a65da65d58..90aca89a10c2e696fd13f0a3808e86574bc2a24e 100644 (file)
 // <http://www.gnu.org/licenses/>.
 
 // { dg-do compile { target c++11 } }
+// COW strings don't support C++11 allocators:
+// { dg-require-effective-target cxx11-abi }
 
 #include <string>
 #include <testsuite_allocator.h>
  
-#if _GLIBCXX_USE_CXX11_ABI
 using C = char;
 const C c = 'a';
 using traits = std::char_traits<C>;
@@ -57,4 +58,3 @@ void test03()
   static_assert( noexcept( v1 = std::move(v2) ), "Move assign cannot throw" );
   static_assert( noexcept( v1.swap(v2) ), "Swap cannot throw" );
 }
-#endif
index 602d856e283503b11705750f1a964d60434a15f7..a7d9bdf96c45abde0532ee2906cb0875d42bed87 100644 (file)
 // <http://www.gnu.org/licenses/>.
 
 // { dg-do run { target c++11 } }
+// COW strings don't support C++11 allocators:
+// { dg-require-effective-target cxx11-abi }
 
 #include <string>
 #include <testsuite_hooks.h>
 #include <testsuite_allocator.h>
  
-#if _GLIBCXX_USE_CXX11_ABI
 using C = char;
 const C c = 'a';
 using traits = std::char_traits<C>;
@@ -79,9 +80,3 @@ int main()
   test02();
   return 0;
 }
-#else
-int main()
-{
-  // COW strings don't support C++11 allocators
-}
-#endif
index 747a2d0796761ec0c0faab69cbc51e41d950f9a3..add276c4e71a44ae3d3e9e79ac073a910fccd46a 100644 (file)
 // <http://www.gnu.org/licenses/>.
 
 // { dg-do run { target c++11 } }
+// COW strings don't support C++11 allocators:
+// { dg-require-effective-target cxx11-abi }
 
 #include <string>
 #include <testsuite_hooks.h>
 #include <testsuite_allocator.h>
  
-#if _GLIBCXX_USE_CXX11_ABI
 using C = wchar_t;
 const C c = L'a';
 using traits = std::char_traits<C>;
@@ -86,9 +87,3 @@ int main()
   test03();
   return 0;
 }
-#else
-int main()
-{
-  // COW strings don't support C++11 allocators
-}
-#endif
index 775755653c990792b3db3dde8b20a46937461a03..89593ba8faa9e18abd4ed98cd93dfcd65fcf7808 100644 (file)
 // <http://www.gnu.org/licenses/>.
 
 // { dg-do run { target c++11 } }
+// COW strings don't support C++11 allocators:
+// { dg-require-effective-target cxx11-abi }
 
 #include <string>
 #include <testsuite_hooks.h>
 #include <testsuite_allocator.h>
  
-#if _GLIBCXX_USE_CXX11_ABI
 using C = wchar_t;
 const C c = L'a';
 using traits = std::char_traits<C>;
@@ -104,9 +105,3 @@ int main()
   test02();
   return 0;
 }
-#else
-int main()
-{
-  // COW strings don't support C++11 allocators
-}
-#endif
index dab694eefe1df4d87976307ab2ca711dcee1ae37..f8e98853c16d8535012e2db03654173cc5edf108 100644 (file)
 // <http://www.gnu.org/licenses/>.
 
 // { dg-do run { target c++11 } }
+// COW strings don't support C++11 allocators:
+// { dg-require-effective-target cxx11-abi }
 
 #include <string>
 #include <memory>
 #include <testsuite_hooks.h>
 #include <testsuite_allocator.h>
  
-#if _GLIBCXX_USE_CXX11_ABI
 using C = wchar_t;
 const C c = L'a';
 using traits = std::char_traits<C>;
@@ -40,9 +41,6 @@ void test01()
   v.assign(1, c);
   v.assign(100, c);
 }
-#else
-void test01() { }
-#endif
 
 int main()
 {
index 7aba440565768006669484e29b660addf4eef680..8db947fd8ff0e1ebbbfdcbdac9bdca69f411c062 100644 (file)
 // <http://www.gnu.org/licenses/>.
 
 // { dg-do run { target c++11 } }
+// COW strings don't support C++11 allocators:
+// { dg-require-effective-target cxx11-abi }
 
 #include <string>
 #include <testsuite_hooks.h>
 #include <testsuite_allocator.h>
 
-#if _GLIBCXX_USE_CXX11_ABI
 using C = wchar_t;
 const C c = L'a';
 using traits = std::char_traits<C>;
@@ -56,9 +57,3 @@ int main()
   test02();
   return 0;
 }
-#else
-int main()
-{
-  // COW strings don't support C++11 allocators
-}
-#endif
index 55b8c2a821c9b9fc61899ab4023a6d06d0d8eb49..9d282fcec9453082a0fc5f59dd613ddc487b0071 100644 (file)
 // <http://www.gnu.org/licenses/>.
 
 // { dg-do run { target c++11 } }
+// COW strings don't support C++11 allocators:
+// { dg-require-effective-target cxx11-abi }
 
 #include <string>
 #include <testsuite_hooks.h>
 #include <testsuite_allocator.h>
  
-#if _GLIBCXX_USE_CXX11_ABI
 using C = wchar_t;
 const C c = L'a';
 using traits = std::char_traits<C>;
@@ -149,9 +150,3 @@ int main()
   test03();
   return 0;
 }
-#else
-int main()
-{
-  // COW strings don't support C++11 allocators
-}
-#endif
index 27548282fc45aab78d36d34eca448b79684cd0c7..c107737ee7023af95fe56944584cb229206e3dac 100644 (file)
 // <http://www.gnu.org/licenses/>.
 
 // { dg-do compile { target c++11 } }
+// COW strings don't support C++11 allocators:
+// { dg-require-effective-target cxx11-abi }
 
 #include <string>
 #include <testsuite_allocator.h>
  
-#if _GLIBCXX_USE_CXX11_ABI
 using C = wchar_t;
 const C c = L'a';
 using traits = std::char_traits<C>;
@@ -57,4 +58,3 @@ void test03()
   static_assert( noexcept( v1 = std::move(v2) ), "Move assign cannot throw" );
   static_assert( noexcept( v1.swap(v2) ), "Swap cannot throw" );
 }
-#endif
index bb1dd8252b766d8e544daf0abb942f86345f140d..842fb55d6e622071c72f85bcc7786149473ab6ad 100644 (file)
 // <http://www.gnu.org/licenses/>.
 
 // { dg-do run { target c++11 } }
+// COW strings don't support C++11 allocators:
+// { dg-require-effective-target cxx11-abi }
 
 #include <string>
 #include <testsuite_hooks.h>
 #include <testsuite_allocator.h>
  
-#if _GLIBCXX_USE_CXX11_ABI
 using C = wchar_t;
 const C c = L'a';
 using traits = std::char_traits<C>;
@@ -79,9 +80,3 @@ int main()
   test02();
   return 0;
 }
-#else
-int main()
-{
-  // COW strings don't support C++11 allocators
-}
-#endif
index bf5a20da45c8f757d00dde8fff20a224ad7e7924..526ab329fa59fceba66560e4859e7acf9cf521d3 100644 (file)
@@ -1,6 +1,7 @@
-// { dg-options "-O2 -D_GLIBCXX_USE_CXX11_ABI" }
+// { dg-options "-O2" }
 // { dg-do run { target c++11 } }
 // { dg-require-normal-mode "" }
+// { dg-require-effective-target cxx11-abi }
 
 // Copyright (C) 2015-2017 Free Software Foundation, Inc.
 //
index 21fa2e641771ae123ffa250d3db3223d50c7a5c5..3b9436dedf096e1ce05aa6494de41425a1168984 100644 (file)
@@ -15,8 +15,9 @@
 // with this library; see the file COPYING3.  If not see
 // <http://www.gnu.org/licenses/>.
 
-// { dg-options "-O0 -D_GLIBCXX_USE_CXX11_ABI=1" }
+// { dg-options "-O0" }
 // { dg-do link { target c++11 } }
+// { dg-require-effective-target cxx11-abi }
 
 #include <fstream>
 #include <string>
index 99ad9292381c6c397e61b6cbea9a2059a2364c23..46b68b1c961ac9696968208064cf839bc6b39c68 100644 (file)
 // <http://www.gnu.org/licenses/>.
 
 // { dg-do run { target c++11 } }
+// { dg-require-effective-target cxx11-abi }
 
 #include <ios>
 #include <testsuite_hooks.h>
 
-#if _GLIBCXX_USE_CXX11_ABI
 using test_type = std::ios_base::failure;
 
 static_assert( std::is_base_of<std::system_error, test_type>::value, "base" );
@@ -51,6 +51,3 @@ main()
   test01();
   test02();
 }
-#else
-int main() { }
-#endif
index 9f0e26b872506adbc1a4daefb54c06ee4cb2658a..b081d8a5b9007144de77cdccdc54a8b3aa14d93c 100644 (file)
@@ -1968,7 +1968,7 @@ proc check_v3_target_filesystem_ts { } {
        close $f
 
        set cxxflags_saved $cxxflags
-       set cxxflags "$cxxflags $DEFAULT_CXXFLAGS -Werror -std=gnu++11"
+       set cxxflags "$cxxflags $DEFAULT_CXXFLAGS -Werror"
 
        set lines [v3_target_compile $src /dev/null preprocess ""]
        set cxxflags $cxxflags_saved
@@ -1983,6 +1983,34 @@ proc check_v3_target_filesystem_ts { } {
     return $et_filesystem_ts
 }
 
+# Return 1 if the "cxx11" ABI is in use using the current flags, 0 otherwise.
+proc check_effective_target_cxx11-abi { } {
+    global cxxflags
+
+    # Set up and preprocess a C++ test program that depends
+    # on the new ABI being enabled.
+    set src cxx11_abi[pid].cc
+
+    set f [open $src "w"]
+    puts $f "#include <bits/c++config.h>"
+    puts $f "#if ! _GLIBCXX_USE_CXX11_ABI"
+    puts $f "#  error old ABI in use"
+    puts $f "#endif"
+    close $f
+
+    set lines [v3_target_compile $src /dev/null preprocess ""]
+    file delete $src
+
+    if [string match "" $lines] {
+        # No error message, preprocessing succeeded.
+        verbose "check_v3_cxx11_abi: `1'" 2
+        return 1
+    }
+
+    verbose "check_v3_cxx11_abi: `0'" 2
+    return 0
+}
+
 set additional_prunes ""
 
 if { [info exists env(GCC_RUNTEST_PARALLELIZE_DIR)] \