From: Paolo Carlini Date: Tue, 30 Nov 2010 12:52:38 +0000 (+0000) Subject: re PR libstdc++/46718 ([c++0x] nullptr_t must be scalar) X-Git-Tag: releases/gcc-4.6.0~2240 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=1e6734153b66968c2dd35dfaaba68ab6bcfde868;p=thirdparty%2Fgcc.git re PR libstdc++/46718 ([c++0x] nullptr_t must be scalar) 2010-11-30 Paolo Carlini PR libstdc++/46718 * include/std/type_traits (__is_nullptr_t): Add. (is_scalar): Use the latter. * testsuite/20_util/is_scalar/value.cc: New. * testsuite/20_util/is_scalar/requirements/typedefs.cc: Likewise. * testsuite/20_util/is_scalar/requirements/explicit_instantiation.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. * testsuite/20_util/declval/requirements/1_neg.cc: Likewise. From-SVN: r167294 --- diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 601fd40e2cd0..f72cb372c135 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,18 @@ +2010-11-30 Paolo Carlini + + PR libstdc++/46718 + * include/std/type_traits (__is_nullptr_t): Add. + (is_scalar): Use the latter. + * testsuite/20_util/is_scalar/value.cc: New. + * testsuite/20_util/is_scalar/requirements/typedefs.cc: Likewise. + * testsuite/20_util/is_scalar/requirements/explicit_instantiation.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. + * testsuite/20_util/declval/requirements/1_neg.cc: Likewise. + 2010-11-28 Jonathan Wakely PR libstdc++/46689 diff --git a/libstdc++-v3/include/std/type_traits b/libstdc++-v3/include/std/type_traits index fe84a6f92acb..8f5b5c993e27 100644 --- a/libstdc++-v3/include/std/type_traits +++ b/libstdc++-v3/include/std/type_traits @@ -250,6 +250,18 @@ _GLIBCXX_BEGIN_NAMESPACE(std) struct is_function<_Res(_ArgTypes......) const volatile> : public true_type { }; + template + struct __is_nullptr_t_helper + : public false_type { }; + _DEFINE_SPEC(0, __is_nullptr_t_helper, std::nullptr_t, true) + + // __is_nullptr_t (extension). + template + struct __is_nullptr_t + : public integral_constant::type>::value)> + { }; + // composite type traits. /// is_arithmetic @@ -284,7 +296,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std) : public integral_constant::value || is_enum<_Tp>::value || is_pointer<_Tp>::value - || is_member_pointer<_Tp>::value)> + || is_member_pointer<_Tp>::value + || __is_nullptr_t<_Tp>::value)> { }; /// is_compound diff --git a/libstdc++-v3/testsuite/20_util/declval/requirements/1_neg.cc b/libstdc++-v3/testsuite/20_util/declval/requirements/1_neg.cc index 65516cca2300..32f2d23f9add 100644 --- a/libstdc++-v3/testsuite/20_util/declval/requirements/1_neg.cc +++ b/libstdc++-v3/testsuite/20_util/declval/requirements/1_neg.cc @@ -19,7 +19,7 @@ // with this library; see the file COPYING3. If not see // . -// { dg-error "static assertion failed" "" { target *-*-* } 1119 } +// { dg-error "static assertion failed" "" { target *-*-* } 1132 } #include diff --git a/libstdc++-v3/testsuite/20_util/is_scalar/requirements/explicit_instantiation.cc b/libstdc++-v3/testsuite/20_util/is_scalar/requirements/explicit_instantiation.cc new file mode 100644 index 000000000000..1ff9ddc74b21 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/is_scalar/requirements/explicit_instantiation.cc @@ -0,0 +1,29 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2010 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 +// . + +// NB: This file is for testing type_traits with NO OTHER INCLUDES. + +#include + +namespace std +{ + typedef short test_type; + template struct is_scalar; +} diff --git a/libstdc++-v3/testsuite/20_util/is_scalar/requirements/typedefs.cc b/libstdc++-v3/testsuite/20_util/is_scalar/requirements/typedefs.cc new file mode 100644 index 000000000000..b2d0dd17c48a --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/is_scalar/requirements/typedefs.cc @@ -0,0 +1,36 @@ +// 2010-11-30 Paolo Carlini +// +// Copyright (C) 2010 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 +// . + +// +// NB: This file is for testing tr1/type_traits with NO OTHER INCLUDES. + +#include + +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +void test01() +{ + // Check for required typedefs + typedef std::is_scalar 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_scalar/value.cc b/libstdc++-v3/testsuite/20_util/is_scalar/value.cc new file mode 100644 index 000000000000..7d6521ed6f4e --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/is_scalar/value.cc @@ -0,0 +1,48 @@ +// { dg-options "-std=gnu++0x" } +// 2010-11-30 Paolo Carlini +// +// Copyright (C) 2010 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 +// . + +#include +#include +#include + +void test01() +{ + bool test __attribute__((unused)) = true; + using std::is_scalar; + using namespace __gnu_test; + + VERIFY( (test_category(true)) ); + VERIFY( (test_category(true)) ); + VERIFY( (test_category(true)) ); + VERIFY( (test_category(true)) ); + VERIFY( (test_category(true)) ); + VERIFY( (test_category(true)) ); + VERIFY( (test_category(true)) ); + VERIFY( (test_category(true)) ); + + // Sanity check. + VERIFY( (test_category(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 fc5744083c9b..205da120f908 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 @@ -48,5 +48,5 @@ void test01() // { dg-error "instantiated from here" "" { target *-*-* } 40 } // { dg-error "instantiated from here" "" { target *-*-* } 42 } -// { dg-error "invalid use of incomplete type" "" { target *-*-* } 1082 } -// { dg-error "declaration of" "" { target *-*-* } 1046 } +// { dg-error "invalid use of incomplete type" "" { target *-*-* } 1095 } +// { dg-error "declaration of" "" { target *-*-* } 1059 } 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 abbaefd65a7c..c6e00075178b 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 @@ -48,5 +48,5 @@ void test01() // { dg-error "instantiated from here" "" { target *-*-* } 40 } // { dg-error "instantiated from here" "" { target *-*-* } 42 } -// { dg-error "invalid use of incomplete type" "" { target *-*-* } 1005 } -// { dg-error "declaration of" "" { target *-*-* } 969 } +// { dg-error "invalid use of incomplete type" "" { target *-*-* } 1018 } +// { dg-error "declaration of" "" { target *-*-* } 982 }