[PATCH] Define cxx11-abi effective target for libstdc++ tests

Jonathan Wakely jwakely@redhat.com
Fri Jan 13 14:57:00 GMT 2017


This effective target means we can skip/xfail tests that depend on the
new std::string, std::list etc.

I've added the check_effective_target_cxx11 procedure in libstdc++.exp
not in gcc/testsuite/lib/target-supports.exp because I don't think it
is useful outside the libstdc++ testsuite.

There are still lots of tests that fail when run with
-D_GLIBCXX_USE_CXX11_ABI=0 but I plan to fix them by adding the
missing features, not skipping the tests.

	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.

Tested powerpc64le-linux, committed to trunk.


-------------- next part --------------
commit 85ad51f9d27151ad8e070b5d19aef98f1c607bb1
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Fri Jan 13 11:18:36 2017 +0000

    Define cxx11-abi effective target for libstdc++ tests
    
    	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.

diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/allocator/71964.cc b/libstdc++-v3/testsuite/21_strings/basic_string/allocator/71964.cc
index f5ef176..70e5cf8 100644
--- a/libstdc++-v3/testsuite/21_strings/basic_string/allocator/71964.cc
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/allocator/71964.cc
@@ -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
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/allocator/char/copy.cc b/libstdc++-v3/testsuite/21_strings/basic_string/allocator/char/copy.cc
index 0e5f167..bdcadaf 100644
--- a/libstdc++-v3/testsuite/21_strings/basic_string/allocator/char/copy.cc
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/allocator/char/copy.cc
@@ -16,12 +16,13 @@
 // <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
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/allocator/char/copy_assign.cc b/libstdc++-v3/testsuite/21_strings/basic_string/allocator/char/copy_assign.cc
index 5b9a0b0..32ee708 100644
--- a/libstdc++-v3/testsuite/21_strings/basic_string/allocator/char/copy_assign.cc
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/allocator/char/copy_assign.cc
@@ -16,12 +16,13 @@
 // <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
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/allocator/char/minimal.cc b/libstdc++-v3/testsuite/21_strings/basic_string/allocator/char/minimal.cc
index 6f0aeb5..46b4215 100644
--- a/libstdc++-v3/testsuite/21_strings/basic_string/allocator/char/minimal.cc
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/allocator/char/minimal.cc
@@ -16,13 +16,14 @@
 // <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()
 {
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/allocator/char/move.cc b/libstdc++-v3/testsuite/21_strings/basic_string/allocator/char/move.cc
index 4e45a05..820b3ed 100644
--- a/libstdc++-v3/testsuite/21_strings/basic_string/allocator/char/move.cc
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/allocator/char/move.cc
@@ -16,12 +16,13 @@
 // <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
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/allocator/char/move_assign.cc b/libstdc++-v3/testsuite/21_strings/basic_string/allocator/char/move_assign.cc
index 0151a29..df85a0b 100644
--- a/libstdc++-v3/testsuite/21_strings/basic_string/allocator/char/move_assign.cc
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/allocator/char/move_assign.cc
@@ -16,12 +16,13 @@
 // <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
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/allocator/char/noexcept.cc b/libstdc++-v3/testsuite/21_strings/basic_string/allocator/char/noexcept.cc
index b7917e0..90aca89 100644
--- a/libstdc++-v3/testsuite/21_strings/basic_string/allocator/char/noexcept.cc
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/allocator/char/noexcept.cc
@@ -16,11 +16,12 @@
 // <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
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/allocator/char/swap.cc b/libstdc++-v3/testsuite/21_strings/basic_string/allocator/char/swap.cc
index 602d856..a7d9bdf 100644
--- a/libstdc++-v3/testsuite/21_strings/basic_string/allocator/char/swap.cc
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/allocator/char/swap.cc
@@ -16,12 +16,13 @@
 // <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
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/allocator/wchar_t/copy.cc b/libstdc++-v3/testsuite/21_strings/basic_string/allocator/wchar_t/copy.cc
index 747a2d0..add276c 100644
--- a/libstdc++-v3/testsuite/21_strings/basic_string/allocator/wchar_t/copy.cc
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/allocator/wchar_t/copy.cc
@@ -16,12 +16,13 @@
 // <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
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/allocator/wchar_t/copy_assign.cc b/libstdc++-v3/testsuite/21_strings/basic_string/allocator/wchar_t/copy_assign.cc
index 7757556..89593ba 100644
--- a/libstdc++-v3/testsuite/21_strings/basic_string/allocator/wchar_t/copy_assign.cc
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/allocator/wchar_t/copy_assign.cc
@@ -16,12 +16,13 @@
 // <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
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/allocator/wchar_t/minimal.cc b/libstdc++-v3/testsuite/21_strings/basic_string/allocator/wchar_t/minimal.cc
index dab694e..f8e9885 100644
--- a/libstdc++-v3/testsuite/21_strings/basic_string/allocator/wchar_t/minimal.cc
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/allocator/wchar_t/minimal.cc
@@ -16,13 +16,14 @@
 // <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()
 {
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/allocator/wchar_t/move.cc b/libstdc++-v3/testsuite/21_strings/basic_string/allocator/wchar_t/move.cc
index 7aba440..8db947f 100644
--- a/libstdc++-v3/testsuite/21_strings/basic_string/allocator/wchar_t/move.cc
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/allocator/wchar_t/move.cc
@@ -16,12 +16,13 @@
 // <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
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/allocator/wchar_t/move_assign.cc b/libstdc++-v3/testsuite/21_strings/basic_string/allocator/wchar_t/move_assign.cc
index 55b8c2a..9d282fc 100644
--- a/libstdc++-v3/testsuite/21_strings/basic_string/allocator/wchar_t/move_assign.cc
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/allocator/wchar_t/move_assign.cc
@@ -16,12 +16,13 @@
 // <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
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/allocator/wchar_t/noexcept.cc b/libstdc++-v3/testsuite/21_strings/basic_string/allocator/wchar_t/noexcept.cc
index 2754828..c107737 100644
--- a/libstdc++-v3/testsuite/21_strings/basic_string/allocator/wchar_t/noexcept.cc
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/allocator/wchar_t/noexcept.cc
@@ -16,11 +16,12 @@
 // <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
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/allocator/wchar_t/swap.cc b/libstdc++-v3/testsuite/21_strings/basic_string/allocator/wchar_t/swap.cc
index bb1dd82..842fb55 100644
--- a/libstdc++-v3/testsuite/21_strings/basic_string/allocator/wchar_t/swap.cc
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/allocator/wchar_t/swap.cc
@@ -16,12 +16,13 @@
 // <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
diff --git a/libstdc++-v3/testsuite/23_containers/list/61347.cc b/libstdc++-v3/testsuite/23_containers/list/61347.cc
index bf5a20d..526ab32 100644
--- a/libstdc++-v3/testsuite/23_containers/list/61347.cc
+++ b/libstdc++-v3/testsuite/23_containers/list/61347.cc
@@ -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.
 //
diff --git a/libstdc++-v3/testsuite/27_io/basic_fstream/cons/base.cc b/libstdc++-v3/testsuite/27_io/basic_fstream/cons/base.cc
index 21fa2e6..3b9436d 100644
--- a/libstdc++-v3/testsuite/27_io/basic_fstream/cons/base.cc
+++ b/libstdc++-v3/testsuite/27_io/basic_fstream/cons/base.cc
@@ -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>
diff --git a/libstdc++-v3/testsuite/27_io/ios_base/failure/cxx11.cc b/libstdc++-v3/testsuite/27_io/ios_base/failure/cxx11.cc
index 99ad929..46b68b1 100644
--- a/libstdc++-v3/testsuite/27_io/ios_base/failure/cxx11.cc
+++ b/libstdc++-v3/testsuite/27_io/ios_base/failure/cxx11.cc
@@ -16,11 +16,11 @@
 // <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
diff --git a/libstdc++-v3/testsuite/lib/libstdc++.exp b/libstdc++-v3/testsuite/lib/libstdc++.exp
index 9f0e26b..b081d8a 100644
--- a/libstdc++-v3/testsuite/lib/libstdc++.exp
+++ b/libstdc++-v3/testsuite/lib/libstdc++.exp
@@ -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)] \


More information about the Gcc-patches mailing list