]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
type_traits (is_null_pointer): Add.
authorPaolo Carlini <paolo.carlini@oracle.com>
Thu, 2 May 2013 11:00:26 +0000 (11:00 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Thu, 2 May 2013 11:00:26 +0000 (11:00 +0000)
2013-05-02  Paolo Carlini  <paolo.carlini@oracle.com>

* include/std/type_traits (is_null_pointer): Add.
(__is_nullptr_t): Implement in terms of the latter.
(is_fundamental, is_scalar): Adjust.
* testsuite/20_util/is_null_pointer/requirements/
explicit_instantiation.cc: New.
* testsuite/20_util/is_null_pointer/requirements/typedefs.cc:
Likewise.
* testsuite/20_util/is_null_pointer/value.cc: Likewise.
* testsuite/20_util/declval/requirements/1_neg.cc: Adjust dg-error
line number.
* testsuite/20_util/make_signed/requirements/typedefs_neg.cc:
Likewise.
* testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc:
Likewise.

From-SVN: r198516

libstdc++-v3/ChangeLog
libstdc++-v3/include/std/type_traits
libstdc++-v3/testsuite/20_util/declval/requirements/1_neg.cc
libstdc++-v3/testsuite/20_util/is_null_pointer/requirements/explicit_instantiation.cc [new file with mode: 0644]
libstdc++-v3/testsuite/20_util/is_null_pointer/requirements/typedefs.cc [new file with mode: 0644]
libstdc++-v3/testsuite/20_util/is_null_pointer/value.cc [new file with mode: 0644]
libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs_neg.cc
libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc

index dbc15fcbc1cd9da52311b9b51d863e27929f498b..b57163e5289b994b7bd6f06bf67fa5168b6ac2e5 100644 (file)
@@ -1,3 +1,20 @@
+2013-05-02  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       * include/std/type_traits (is_null_pointer): Add.
+       (__is_nullptr_t): Implement in terms of the latter.
+       (is_fundamental, is_scalar): Adjust.
+       * testsuite/20_util/is_null_pointer/requirements/
+       explicit_instantiation.cc: New.
+       * testsuite/20_util/is_null_pointer/requirements/typedefs.cc:
+       Likewise.
+       * testsuite/20_util/is_null_pointer/value.cc: Likewise.
+       * testsuite/20_util/declval/requirements/1_neg.cc: Adjust dg-error
+       line number.
+       * testsuite/20_util/make_signed/requirements/typedefs_neg.cc:
+       Likewise.
+       * testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc:
+       Likewise.
+
 2013-05-02  Paolo Carlini  <paolo.carlini@oracle.com>
 
        * include/c_global/cstdio: Add comment about LWG 2249.
index 79a9b6ae6903d1ac278c40d6045487972b9a09de..a0a8327bec55879ce5c9879c55a05a6b76361bd5 100644 (file)
@@ -402,17 +402,23 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     : public true_type { };
 
   template<typename>
-    struct __is_nullptr_t_helper
+    struct __is_null_pointer_helper
     : public false_type { };
 
   template<>
-    struct __is_nullptr_t_helper<std::nullptr_t>
+    struct __is_null_pointer_helper<std::nullptr_t>
     : public true_type { };
 
-  // __is_nullptr_t (extension).
+  /// is_null_pointer (LWG 2247).
+  template<typename _Tp>
+    struct is_null_pointer
+    : public __is_null_pointer_helper<typename remove_cv<_Tp>::type>::type
+    { };
+
+  /// __is_nullptr_t (extension).
   template<typename _Tp>
     struct __is_nullptr_t
-    : public __is_nullptr_t_helper<typename remove_cv<_Tp>::type>::type
+    : public is_null_pointer<_Tp>
     { };
 
   // Composite type categories.
@@ -433,7 +439,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   /// is_fundamental
   template<typename _Tp>
     struct is_fundamental
-    : public __or_<is_arithmetic<_Tp>, is_void<_Tp>, __is_nullptr_t<_Tp>>::type
+    : public __or_<is_arithmetic<_Tp>, is_void<_Tp>,
+                  is_null_pointer<_Tp>>::type
     { };
 
   /// is_object
@@ -450,7 +457,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   template<typename _Tp>
     struct is_scalar
     : public __or_<is_arithmetic<_Tp>, is_enum<_Tp>, is_pointer<_Tp>,
-                   is_member_pointer<_Tp>, __is_nullptr_t<_Tp>>::type
+                   is_member_pointer<_Tp>, is_null_pointer<_Tp>>::type
     { };
 
   /// is_compound
index 02347d1685e04d0552c795043f568325a1009042..ad821905a063f3434b533a6debd1b6e75f84a9f5 100644 (file)
@@ -19,7 +19,7 @@
 // with this library; see the file COPYING3.  If not see
 // <http://www.gnu.org/licenses/>.
 
-// { dg-error "static assertion failed" "" { target *-*-* } 1852 }
+// { dg-error "static assertion failed" "" { target *-*-* } 1859 }
 
 #include <utility>
 
diff --git a/libstdc++-v3/testsuite/20_util/is_null_pointer/requirements/explicit_instantiation.cc b/libstdc++-v3/testsuite/20_util/is_null_pointer/requirements/explicit_instantiation.cc
new file mode 100644 (file)
index 0000000..9df6719
--- /dev/null
@@ -0,0 +1,30 @@
+// { dg-options "-std=gnu++11" }
+// { dg-do compile }
+// 2013-05-02  Paolo Carlini  <paolo.carlini@oracle.com>
+
+// Copyright (C) 2013 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_null_pointer<test_type>;
+}
diff --git a/libstdc++-v3/testsuite/20_util/is_null_pointer/requirements/typedefs.cc b/libstdc++-v3/testsuite/20_util/is_null_pointer/requirements/typedefs.cc
new file mode 100644 (file)
index 0000000..057d964
--- /dev/null
@@ -0,0 +1,36 @@
+// { dg-options "-std=gnu++11" }
+// 2013-05-02  Paolo Carlini  <paolo.carlini@oracle.com>
+//
+// Copyright (C) 2013 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>
+
+// { dg-do compile }
+
+void test01()
+{
+  // Check for required typedefs
+  typedef std::is_null_pointer<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_null_pointer/value.cc b/libstdc++-v3/testsuite/20_util/is_null_pointer/value.cc
new file mode 100644 (file)
index 0000000..2bee73a
--- /dev/null
@@ -0,0 +1,60 @@
+// { dg-options "-std=gnu++11" }
+// 2013-05-02  Paolo Carlini  <pcarlini@suse.de>
+//
+// Copyright (C) 2013 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_null_pointer;
+  using namespace __gnu_test;
+
+  VERIFY( (test_category<is_null_pointer, std::nullptr_t>(true)) );
+
+  VERIFY( (test_category<is_null_pointer, int>(false)) );
+  VERIFY( (test_category<is_null_pointer, float>(false)) );
+  VERIFY( (test_category<is_null_pointer, EnumType>(false)) );
+  VERIFY( (test_category<is_null_pointer, int*>(false)) );
+  VERIFY( (test_category<is_null_pointer, int(*)(int)>(false)) );
+  VERIFY( (test_category<is_null_pointer, int (ClassType::*)>(false)) );
+  VERIFY( (test_category<is_null_pointer, int (ClassType::*) (int)>(false)) );
+  VERIFY( (test_category<is_null_pointer, int[2]>(false)) );
+  VERIFY( (test_category<is_null_pointer, float[][3]>(false)) );
+  VERIFY( (test_category<is_null_pointer, EnumType[2][3][4]>(false)) );
+  VERIFY( (test_category<is_null_pointer, int*[3]>(false)) );
+  VERIFY( (test_category<is_null_pointer, int(*[][2])(int)>(false)) );
+  VERIFY( (test_category<is_null_pointer, int (ClassType::*[2][3])>(false)) );
+  VERIFY( (test_category<is_null_pointer,
+          int (ClassType::*[][2][3]) (int)>(false)) );
+  VERIFY( (test_category<is_null_pointer, ClassType>(false)) );
+  VERIFY( (test_category<is_null_pointer, PODType>(false)) );
+  VERIFY( (test_category<is_null_pointer, void>(false)) );
+  VERIFY( (test_category<is_null_pointer, NType>(false)) );
+  VERIFY( (test_category<is_null_pointer, TType>(false)) );
+  VERIFY( (test_category<is_null_pointer, SLType>(false)) );
+}
+
+int main()
+{
+  test01();
+  return 0;
+}
index b2d5d770e63a767a17a26dd4244de22fe0e50e19..077e32797a66d1b5a555dcb8c13c8d83aad124fb 100644 (file)
@@ -48,5 +48,5 @@ void test01()
 // { dg-error "required from here" "" { target *-*-* } 40 }
 // { dg-error "required from here" "" { target *-*-* } 42 }
 
-// { dg-error "invalid use of incomplete type" "" { target *-*-* } 1594 }
-// { dg-error "declaration of" "" { target *-*-* } 1558 }
+// { dg-error "invalid use of incomplete type" "" { target *-*-* } 1601 }
+// { dg-error "declaration of" "" { target *-*-* } 1565 }
index 8980fe1ba8f1ba51e6c3c8393f141c40b50f013c..2bc1cbbad12d358dbd856bef4cb33cec2ef3c43c 100644 (file)
@@ -48,5 +48,5 @@ void test01()
 // { dg-error "required from here" "" { target *-*-* } 40 }
 // { dg-error "required from here" "" { target *-*-* } 42 }
 
-// { dg-error "invalid use of incomplete type" "" { target *-*-* } 1512 }
-// { dg-error "declaration of" "" { target *-*-* } 1476 }
+// { dg-error "invalid use of incomplete type" "" { target *-*-* } 1519 }
+// { dg-error "declaration of" "" { target *-*-* } 1483 }