Patchwork [v3] adjust tests to work in c++0x mode

login
register
mail settings
Submitter Jonathan Wakely
Date June 23, 2011, 10:32 a.m.
Message ID <BANLkTi=8jMZ9CrvFDf4gbRpGb8LgSyGWeQ@mail.gmail.com>
Download mbox | patch
Permalink /patch/101606/
State New
Headers show

Comments

Jonathan Wakely - June 23, 2011, 10:32 a.m.
This changes a few tests so they still work when the testsuite is run
in c++0x mode, adding _GLIBCXX_CONSTEXPR to some declarations and
qualifying some TR1 names to disambiguate them from the same names in
namespace std.  I think this is the right way to handle the failures.

        * testsuite/tr1/6_containers/tuple/creation_functions/tie2.cc: Fix for
        C++0x mode.
        * testsuite/25_algorithms/sort/35588.cc: Likewise.
        * testsuite/26_numerics/headers/complex/synopsis.cc: Likewise.

Tested on x86_64-linux, with and without -std=gnu++0x

There's still one more failure like this in
tr1/6_containers/utility/pair.cc, which needs every 'get' to be
qualified as tr1::get, which I can't be bothered to do today!

Patch

Index: testsuite/25_algorithms/sort/35588.cc
===================================================================
--- testsuite/25_algorithms/sort/35588.cc	(revision 174948)
+++ testsuite/25_algorithms/sort/35588.cc	(working copy)
@@ -23,9 +23,8 @@ 
 int main()
 {
   using namespace std;
-  using namespace tr1;
   using namespace std::tr1::placeholders;
 
   int t[10];
-  sort(t, t+10, bind(less<int>(), _1, _2));
+  sort(t, t+10, tr1::bind(less<int>(), _1, _2));
 }
Index: testsuite/26_numerics/headers/complex/synopsis.cc
===================================================================
--- testsuite/26_numerics/headers/complex/synopsis.cc	(revision 174948)
+++ testsuite/26_numerics/headers/complex/synopsis.cc	(working copy)
@@ -44,15 +44,20 @@ 
   template<class T> complex<T> operator/(const T&, const complex<T>&);
   template<class T> complex<T> operator+(const complex<T>&);
   template<class T> complex<T> operator-(const complex<T>&);
-  template<class T> bool operator==
+  template<class T> _GLIBCXX_CONSTEXPR bool operator==
     (const complex<T>&, const complex<T>&);
-  template<class T> bool operator==(const complex<T>&, const T&);
-  template<class T> bool operator==(const T&, const complex<T>&);
+  template<class T> _GLIBCXX_CONSTEXPR bool operator==
+    (const complex<T>&, const T&);
+  template<class T> _GLIBCXX_CONSTEXPR bool operator==
+    (const T&, const complex<T>&);
 
 
-  template<class T> bool operator!=(const complex<T>&, const complex<T>&);
-  template<class T> bool operator!=(const complex<T>&, const T&);
-  template<class T> bool operator!=(const T&, const complex<T>&);
+  template<class T> _GLIBCXX_CONSTEXPR bool operator!=
+    (const complex<T>&, const complex<T>&);
+  template<class T> _GLIBCXX_CONSTEXPR bool operator!=
+    (const complex<T>&, const T&);
+  template<class T> _GLIBCXX_CONSTEXPR bool operator!=
+    (const T&, const complex<T>&);
   template<class T, class charT, class traits>
   basic_istream<charT, traits>&
   operator>>(basic_istream<charT, traits>&, complex<T>&);
@@ -61,8 +66,8 @@ 
   operator<<(basic_ostream<charT, traits>&, const complex<T>&);
 
   // 26.2.7 values:
-  template<class T> T real(const complex<T>&);
-  template<class T> T imag(const complex<T>&);
+  template<class T> _GLIBCXX_CONSTEXPR T real(const complex<T>&);
+  template<class T> _GLIBCXX_CONSTEXPR T imag(const complex<T>&);
   template<class T> T abs(const complex<T>&);
   template<class T> T arg(const complex<T>&);
   template<class T> T norm(const complex<T>&);
Index: testsuite/tr1/6_containers/tuple/creation_functions/tie2.cc
===================================================================
--- testsuite/tr1/6_containers/tuple/creation_functions/tie2.cc	(revision 174948)
+++ testsuite/tr1/6_containers/tuple/creation_functions/tie2.cc	(working copy)
@@ -30,7 +30,7 @@ 
   int i;
   std::string s;
 
-  tie(i, ignore, s) = make_tuple(42, 3.14, "C++");
+  std::tr1::tie(i, ignore, s) = make_tuple(42, 3.14, "C++");
   VERIFY( i == 42 );
   VERIFY( s == "C++" );
 }