aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3
diff options
context:
space:
mode:
authorPaolo Carlini <paolo.carlini@oracle.com>2009-10-29 23:23:29 +0000
committerPaolo Carlini <paolo@gcc.gnu.org>2009-10-29 23:23:29 +0000
commit2d0269f68336b0ca347594bec9d10d804717a76e (patch)
tree06f6a1ed4e798a4d744ea5690f84a4528af3117e /libstdc++-v3
parent28a371ae13e22365d9d46b2ec4222b15bd82fe43 (diff)
downloadgcc-2d0269f68336b0ca347594bec9d10d804717a76e.zip
gcc-2d0269f68336b0ca347594bec9d10d804717a76e.tar.gz
gcc-2d0269f68336b0ca347594bec9d10d804717a76e.tar.bz2
type_traits (__is_int_or_cref): Remove.
2009-10-29 Paolo Carlini <paolo.carlini@oracle.com> * include/std/type_traits (__is_int_or_cref): Remove. (__is_convertible_helper): Fix per C++0x and simplify (the hack to suppress warnings isn't necessary anymore). * testsuite/20_util/is_convertible/requirements/typedefs.cc: New. * testsuite/20_util/is_convertible/requirements/ explicit_instantiation.cc: Likewise. * testsuite/20_util/is_convertible/value.cc: Likewise. * testsuite/20_util/make_signed/requirements/typedefs_neg.cc: Adjust dg-error line numbers. * testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc: Likewise. From-SVN: r153728
Diffstat (limited to 'libstdc++-v3')
-rw-r--r--libstdc++-v3/ChangeLog14
-rw-r--r--libstdc++-v3/include/std/type_traits26
-rw-r--r--libstdc++-v3/testsuite/20_util/is_convertible/requirements/explicit_instantiation.cc31
-rw-r--r--libstdc++-v3/testsuite/20_util/is_convertible/requirements/typedefs.cc36
-rw-r--r--libstdc++-v3/testsuite/20_util/is_convertible/value.cc102
-rw-r--r--libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs_neg.cc6
-rw-r--r--libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc6
7 files changed, 194 insertions, 27 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index 2f3f9dc..2929d5a 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,5 +1,19 @@
2009-10-29 Paolo Carlini <paolo.carlini@oracle.com>
+ * include/std/type_traits (__is_int_or_cref): Remove.
+ (__is_convertible_helper): Fix per C++0x and simplify (the hack to
+ suppress warnings isn't necessary anymore).
+ * testsuite/20_util/is_convertible/requirements/typedefs.cc: New.
+ * testsuite/20_util/is_convertible/requirements/
+ explicit_instantiation.cc: Likewise.
+ * testsuite/20_util/is_convertible/value.cc: Likewise.
+ * testsuite/20_util/make_signed/requirements/typedefs_neg.cc: Adjust
+ dg-error line numbers.
+ * testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc:
+ Likewise.
+
+2009-10-29 Paolo Carlini <paolo.carlini@oracle.com>
+
* testsuite/20_util/pair/40925.cc: Minor comment fix.
2009-10-29 Paolo Carlini <paolo.carlini@oracle.com>
diff --git a/libstdc++-v3/include/std/type_traits b/libstdc++-v3/include/std/type_traits
index dd26bb8..f5666bc 100644
--- a/libstdc++-v3/include/std/type_traits
+++ b/libstdc++-v3/include/std/type_traits
@@ -253,39 +253,23 @@ namespace std
static const bool __value = sizeof(__test(__makeFrom())) == 1;
};
- template<typename _Tp>
- struct __is_int_or_cref
- {
- typedef typename remove_reference<_Tp>::type __rr_Tp;
- static const bool __value = (is_integral<_Tp>::value
- || (is_integral<__rr_Tp>::value
- && is_const<__rr_Tp>::value
- && !is_volatile<__rr_Tp>::value));
- };
-
template<typename _From, typename _To,
bool = (is_void<_From>::value || is_void<_To>::value
- || is_function<_To>::value || is_array<_To>::value
- // This special case is here only to avoid warnings.
- || (is_floating_point<typename
- remove_reference<_From>::type>::value
- && __is_int_or_cref<_To>::__value))>
+ || is_function<_To>::value || is_array<_To>::value)>
struct __is_convertible_helper
{
- // "An imaginary lvalue of type From...".
static const bool __value = (__is_convertible_simple<typename
- add_lvalue_reference<_From>::type,
+ add_rvalue_reference<_From>::type,
_To>::__value);
};
template<typename _From, typename _To>
struct __is_convertible_helper<_From, _To, true>
- { static const bool __value = (is_void<_To>::value
- || (__is_int_or_cref<_To>::__value
- && !is_void<_From>::value)); };
+ { static const bool __value = (is_void<_From>::value
+ && is_void<_To>::value); };
// XXX FIXME
- // The C++0x specifications are different, see N2255.
+ // The C++0x specifications require front-end support, see N2255.
/// is_convertible
template<typename _From, typename _To>
struct is_convertible
diff --git a/libstdc++-v3/testsuite/20_util/is_convertible/requirements/explicit_instantiation.cc b/libstdc++-v3/testsuite/20_util/is_convertible/requirements/explicit_instantiation.cc
new file mode 100644
index 0000000..646c4b2
--- /dev/null
+++ b/libstdc++-v3/testsuite/20_util/is_convertible/requirements/explicit_instantiation.cc
@@ -0,0 +1,31 @@
+// { dg-options "-std=gnu++0x" }
+// { dg-do compile }
+
+// 2009-10-29 Paolo Carlini <paolo.carlini@oracle.com>
+
+// Copyright (C) 2009 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// NB: This file is for testing type_traits with NO OTHER INCLUDES.
+
+#include <type_traits>
+
+namespace std
+{
+ typedef short test_type;
+ template struct is_convertible<test_type, test_type>;
+}
diff --git a/libstdc++-v3/testsuite/20_util/is_convertible/requirements/typedefs.cc b/libstdc++-v3/testsuite/20_util/is_convertible/requirements/typedefs.cc
new file mode 100644
index 0000000..1e8deb5
--- /dev/null
+++ b/libstdc++-v3/testsuite/20_util/is_convertible/requirements/typedefs.cc
@@ -0,0 +1,36 @@
+// { dg-options "-std=gnu++0x" }
+// { dg-do compile }
+
+// 2009-10-29 Paolo Carlini <paolo.carlini@oracle.com>
+//
+// Copyright (C) 2009 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+//
+// NB: This file is for testing type_traits with NO OTHER INCLUDES.
+
+#include <type_traits>
+
+void test01()
+{
+ // Check for required typedefs
+ typedef std::is_convertible<int, int> test_type;
+ typedef test_type::value_type value_type;
+ typedef test_type::type type;
+ typedef test_type::type::value_type type_value_type;
+ typedef test_type::type::type type_type;
+}
diff --git a/libstdc++-v3/testsuite/20_util/is_convertible/value.cc b/libstdc++-v3/testsuite/20_util/is_convertible/value.cc
new file mode 100644
index 0000000..6ec22d0
--- /dev/null
+++ b/libstdc++-v3/testsuite/20_util/is_convertible/value.cc
@@ -0,0 +1,102 @@
+// { dg-options "-std=gnu++0x" }
+
+// 2009-10-29 Paolo Carlini <paolo.carlini@oracle.com>
+//
+// Copyright (C) 2009 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <type_traits>
+#include <testsuite_hooks.h>
+#include <testsuite_tr1.h>
+
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+ using std::is_convertible;
+ using namespace __gnu_test;
+
+ // Positive tests.
+ VERIFY( (test_relationship<is_convertible, int, int>(true)) );
+ VERIFY( (test_relationship<is_convertible, int, const int>(true)) );
+ VERIFY( (test_relationship<is_convertible, volatile int, const int>(true)) );
+ VERIFY( (test_relationship<is_convertible, int, float>(true)) );
+ VERIFY( (test_relationship<is_convertible, double, float>(true)) );
+ VERIFY( (test_relationship<is_convertible, float, int>(true)) );
+ VERIFY( (test_relationship<is_convertible, int*, const int*>(true)) );
+ VERIFY( (test_relationship<is_convertible, int*, void*>(true)) );
+ VERIFY( (test_relationship<is_convertible, int[4], int*>(true)) );
+ VERIFY( (test_relationship<is_convertible, float&, int>(true)) );
+ VERIFY( (test_relationship<is_convertible, int, const int&>(true)) );
+ VERIFY( (test_relationship<is_convertible, const int&, int>(true)) );
+ VERIFY( (test_relationship<is_convertible, float, const int&>(true)) );
+ VERIFY( (test_relationship<is_convertible, int(int), int(*)(int)>(true)) );
+ VERIFY( (test_relationship<is_convertible, int(&)(int), int(*)(int)>(true)) );
+ VERIFY( (test_relationship<is_convertible, EnumType, int>(true)) );
+ VERIFY( (test_relationship<is_convertible, ClassType, ClassType>(true)) );
+ VERIFY( (test_relationship<is_convertible, DerivedType, ClassType>(true)) );
+ VERIFY( (test_relationship<is_convertible, DerivedType*, ClassType*>(true)) );
+ VERIFY( (test_relationship<is_convertible, DerivedType&, ClassType&>(true)) );
+
+ VERIFY( (test_relationship<is_convertible, const int, const int&>(true)) );
+
+ VERIFY( (test_relationship<is_convertible, void, void>(true)) );
+ VERIFY( (test_relationship<is_convertible, const void, void>(true)) );
+ VERIFY( (test_relationship<is_convertible, void, volatile void>(true)) );
+
+ // Negative tests.
+ VERIFY( (test_relationship<is_convertible, const int*, int*>(false)) );
+ VERIFY( (test_relationship<is_convertible, int*, float*>(false)) );
+ VERIFY( (test_relationship<is_convertible, const int[4], int*>(false)) );
+ VERIFY( (test_relationship<is_convertible, int[4], int[4]>(false)) );
+ VERIFY( (test_relationship<is_convertible, const int&, int&>(false)) );
+ VERIFY( (test_relationship<is_convertible, float&, int&>(false)) );
+ VERIFY( (test_relationship<is_convertible, float, volatile int&>(false)) );
+ VERIFY( (test_relationship<is_convertible, int(int), int(int)>(false)) );
+ VERIFY( (test_relationship<is_convertible, int(int), int(*)(void)>(false)) );
+ VERIFY( (test_relationship<is_convertible, int(*)(int),
+ int(&)(int)>(false)) );
+ VERIFY( (test_relationship<is_convertible, int, EnumType>(false)) );
+ VERIFY( (test_relationship<is_convertible, int, ClassType>(false)) );
+ VERIFY( (test_relationship<is_convertible, ClassType, DerivedType>(false)) );
+ VERIFY( (test_relationship<is_convertible, ClassType*,
+ DerivedType*>(false)) );
+ VERIFY( (test_relationship<is_convertible, ClassType&,
+ DerivedType&>(false)) );
+
+ VERIFY( (test_relationship<is_convertible, void, int>(false)) );
+ VERIFY( (test_relationship<is_convertible, void, float>(false)) );
+ VERIFY( (test_relationship<is_convertible, void, int(*)(int)>(false)) );
+
+ // C++0x
+ VERIFY( (test_relationship<is_convertible, int, void>(false)) );
+ VERIFY( (test_relationship<is_convertible, int[4], void>(false)) );
+
+ VERIFY( (test_relationship<is_convertible, int, int&>(false)) );
+ VERIFY( (test_relationship<is_convertible, float,
+ volatile float&>(false)) );
+ VERIFY( (test_relationship<is_convertible, const volatile int,
+ const volatile int&>(false)) );
+ VERIFY( (test_relationship<is_convertible, volatile int,
+ volatile int&>(false)) );
+ VERIFY( (test_relationship<is_convertible, int(int), int(&)(int)>(false)) );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs_neg.cc b/libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs_neg.cc
index 3455462..5b129e8 100644
--- a/libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs_neg.cc
+++ b/libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs_neg.cc
@@ -3,7 +3,7 @@
// 2007-05-03 Benjamin Kosnik <bkoz@redhat.com>
//
-// Copyright (C) 2007, 2009 Free Software Foundation, Inc.
+// Copyright (C) 2007, 2008, 2009 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
@@ -48,8 +48,8 @@ void test01()
// { dg-error "instantiated from here" "" { target *-*-* } 40 }
// { dg-error "instantiated from here" "" { target *-*-* } 42 }
-// { dg-error "invalid use of incomplete type" "" { target *-*-* } 570 }
-// { dg-error "declaration of" "" { target *-*-* } 532 }
+// { dg-error "invalid use of incomplete type" "" { target *-*-* } 554 }
+// { dg-error "declaration of" "" { target *-*-* } 516 }
// { dg-excess-errors "At global scope" }
// { dg-excess-errors "In instantiation of" }
diff --git a/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc b/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc
index 3d3a10a..fc58ffe 100644
--- a/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc
+++ b/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc
@@ -3,7 +3,7 @@
// 2007-05-03 Benjamin Kosnik <bkoz@redhat.com>
//
-// Copyright (C) 2007, 2009 Free Software Foundation, Inc.
+// Copyright (C) 2007, 2008, 2009 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
@@ -48,8 +48,8 @@ void test01()
// { dg-error "instantiated from here" "" { target *-*-* } 40 }
// { dg-error "instantiated from here" "" { target *-*-* } 42 }
-// { dg-error "invalid use of incomplete type" "" { target *-*-* } 491 }
-// { dg-error "declaration of" "" { target *-*-* } 453 }
+// { dg-error "invalid use of incomplete type" "" { target *-*-* } 475 }
+// { dg-error "declaration of" "" { target *-*-* } 437 }
// { dg-excess-errors "At global scope" }
// { dg-excess-errors "In instantiation of" }