From 7b50cdeffbd3fcb4029eee0c0d85f4ea19fcc47f Mon Sep 17 00:00:00 2001 From: Benjamin Kosnik Date: Thu, 3 May 2007 11:49:12 +0000 Subject: type_traits (enable_if): New. 2007-05-03 Benjamin Kosnik * include/std/type_traits (enable_if): New. (conditional): New. (__decay_selector, decay): New. (__cv_selector, __match_cv_qualifiers): New. (__make_unsigned, __make_unsigned_selector, make_unsigned): New. (__make_signed, __make_signed_selector, make_signed): New. (has_trivial_constructor): ... to has_trivial_default_constructor. (has_nothrow_constructor): ... to has_nothrow_default_constructor. (has_trivial_copy): ... to has_trivial_copy_constructor. (has_nothrow_copy): ... to has_nothrow_copy_constructor. * include/tr1/type_traits_fwd: Move to... * include/tr1/type_traitsfwd: ... this, consistency with ios/string/locale forward headers. * include/tr1/type_traits: Adjust include. * include/Makefile.am (tr1_headers): Change type_traits_fwd.h to type_traitsfwd.h. * include/Makefile.in: Regenerate. * testsuite/23_containers/tuple: Move... * testsuite/20_util/tuple:... here. * testsuite/20_util/conditional: New. * testsuite/20_util/conditional/requirements: Same. * testsuite/20_util/conditional/requirements/ explicit_instantiation.cc: Same. * testsuite/20_util/conditional/requirements/typedefs.cc: Same. * testsuite/20_util/decay: Same. * testsuite/20_util/decay/requirements: Same. * testsuite/20_util/decay/requirements/explicit_instantiation.cc: Same. * testsuite/20_util/decay/requirements/typedefs.cc: Same. * testsuite/20_util/enable_if: Same. * testsuite/20_util/enable_if/requirements: Same. * testsuite/20_util/enable_if/requirements/ explicit_instantiation.cc: Same. * testsuite/20_util/enable_if/requirements/typedefs.cc: Same. * testsuite/20_util/enable_if/requirements/typedefs_neg.cc: Same. * testsuite/20_util/has_nothrow_copy_constructor: Same. * testsuite/20_util/has_nothrow_copy_constructor/requirements: Same. * testsuite/20_util/has_nothrow_copy_constructor/requirements/ explicit_instantiation.cc: Same. * testsuite/20_util/has_nothrow_copy_constructor/requirements/ typedefs.cc: Same. * testsuite/20_util/has_nothrow_copy_constructor/value.cc: Same. * testsuite/20_util/has_nothrow_default_constructor: Same. * testsuite/20_util/has_nothrow_default_constructor/requirements: Same. * testsuite/20_util/has_nothrow_default_constructor/requirements/ explicit_instantiation.cc: Same. * testsuite/20_util/has_nothrow_default_constructor/requirements/ typedefs.cc: Same. * testsuite/20_util/has_nothrow_default_constructor/value.cc: Same. * testsuite/20_util/has_trivial_copy_constructor: Same. * testsuite/20_util/has_trivial_copy_constructor/requirements: Same. * testsuite/20_util/has_trivial_copy_constructor/requirements/ explicit_instantiation.cc: Same. * testsuite/20_util/has_trivial_copy_constructor/requirements/ typedefs.cc: Same. * testsuite/20_util/has_trivial_copy_constructor/value.cc: Same. * testsuite/20_util/has_trivial_default_constructor: Same. * testsuite/20_util/has_trivial_default_constructor/requirements: Same. * testsuite/20_util/has_trivial_default_constructor/requirements/ explicit_instantiation.cc: Same. * testsuite/20_util/has_trivial_default_constructor/requirements/ typedefs.cc: Same. * testsuite/20_util/has_trivial_default_constructor/value.cc: Same. * testsuite/20_util/headers/type_traits/types_std_c++0x_neg.cc: Same. * testsuite/20_util/make_signed: Same. * testsuite/20_util/make_signed/requirements: Same. * testsuite/20_util/make_signed/requirements/ explicit_instantiation.cc: Same. * testsuite/20_util/make_signed/requirements/typedefs.cc: Same. * testsuite/20_util/make_signed/requirements/typedefs_neg.cc: Same. * testsuite/20_util/make_unsigned: Same. * testsuite/20_util/make_unsigned/requirements: Same. * testsuite/20_util/make_unsigned/requirements/ explicit_instantiation.cc: Same. * testsuite/20_util/make_unsigned/requirements/typedefs.cc: Same. * testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc: Same. From-SVN: r124374 --- libstdc++-v3/ChangeLog | 81 ++++++ libstdc++-v3/include/Makefile.am | 2 +- libstdc++-v3/include/Makefile.in | 2 +- libstdc++-v3/include/std/type_traits | 300 +++++++++++++++++++++ libstdc++-v3/include/tr1/type_traits | 2 +- libstdc++-v3/include/tr1/type_traits_fwd.h | 222 --------------- libstdc++-v3/include/tr1/type_traitsfwd.h | 222 +++++++++++++++ .../requirements/explicit_instantiation.cc | 41 +++ .../20_util/conditional/requirements/typedefs.cc | 42 +++ .../decay/requirements/explicit_instantiation.cc | 41 +++ .../20_util/decay/requirements/typedefs.cc | 52 ++++ .../requirements/explicit_instantiation.cc | 41 +++ .../20_util/enable_if/requirements/typedefs.cc | 33 +++ .../20_util/enable_if/requirements/typedefs_neg.cc | 36 +++ .../requirements/explicit_instantiation.cc | 40 +++ .../requirements/typedefs.cc | 37 +++ .../20_util/has_nothrow_copy_constructor/value.cc | 54 ++++ .../requirements/explicit_instantiation.cc | 40 +++ .../requirements/typedefs.cc | 37 +++ .../has_nothrow_default_constructor/value.cc | 59 ++++ .../requirements/explicit_instantiation.cc | 40 +++ .../requirements/typedefs.cc | 37 +++ .../20_util/has_trivial_copy_constructor/value.cc | 56 ++++ .../requirements/explicit_instantiation.cc | 40 +++ .../requirements/typedefs.cc | 37 +++ .../has_trivial_default_constructor/value.cc | 59 ++++ .../headers/type_traits/types_std_c++0x_neg.cc | 37 +++ .../requirements/explicit_instantiation.cc | 40 +++ .../20_util/make_signed/requirements/typedefs.cc | 68 +++++ .../make_signed/requirements/typedefs_neg.cc | 53 ++++ .../requirements/explicit_instantiation.cc | 40 +++ .../20_util/make_unsigned/requirements/typedefs.cc | 68 +++++ .../make_unsigned/requirements/typedefs_neg.cc | 53 ++++ .../tuple/requirements/explicit_instantiation.cc | 33 +++ .../tuple/requirements/explicit_instantiation.cc | 33 --- 35 files changed, 1820 insertions(+), 258 deletions(-) delete mode 100644 libstdc++-v3/include/tr1/type_traits_fwd.h create mode 100644 libstdc++-v3/include/tr1/type_traitsfwd.h create mode 100644 libstdc++-v3/testsuite/20_util/conditional/requirements/explicit_instantiation.cc create mode 100644 libstdc++-v3/testsuite/20_util/conditional/requirements/typedefs.cc create mode 100644 libstdc++-v3/testsuite/20_util/decay/requirements/explicit_instantiation.cc create mode 100644 libstdc++-v3/testsuite/20_util/decay/requirements/typedefs.cc create mode 100644 libstdc++-v3/testsuite/20_util/enable_if/requirements/explicit_instantiation.cc create mode 100644 libstdc++-v3/testsuite/20_util/enable_if/requirements/typedefs.cc create mode 100644 libstdc++-v3/testsuite/20_util/enable_if/requirements/typedefs_neg.cc create mode 100644 libstdc++-v3/testsuite/20_util/has_nothrow_copy_constructor/requirements/explicit_instantiation.cc create mode 100644 libstdc++-v3/testsuite/20_util/has_nothrow_copy_constructor/requirements/typedefs.cc create mode 100644 libstdc++-v3/testsuite/20_util/has_nothrow_copy_constructor/value.cc create mode 100644 libstdc++-v3/testsuite/20_util/has_nothrow_default_constructor/requirements/explicit_instantiation.cc create mode 100644 libstdc++-v3/testsuite/20_util/has_nothrow_default_constructor/requirements/typedefs.cc create mode 100644 libstdc++-v3/testsuite/20_util/has_nothrow_default_constructor/value.cc create mode 100644 libstdc++-v3/testsuite/20_util/has_trivial_copy_constructor/requirements/explicit_instantiation.cc create mode 100644 libstdc++-v3/testsuite/20_util/has_trivial_copy_constructor/requirements/typedefs.cc create mode 100644 libstdc++-v3/testsuite/20_util/has_trivial_copy_constructor/value.cc create mode 100644 libstdc++-v3/testsuite/20_util/has_trivial_default_constructor/requirements/explicit_instantiation.cc create mode 100644 libstdc++-v3/testsuite/20_util/has_trivial_default_constructor/requirements/typedefs.cc create mode 100644 libstdc++-v3/testsuite/20_util/has_trivial_default_constructor/value.cc create mode 100644 libstdc++-v3/testsuite/20_util/headers/type_traits/types_std_c++0x_neg.cc create mode 100644 libstdc++-v3/testsuite/20_util/make_signed/requirements/explicit_instantiation.cc create mode 100644 libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs.cc create mode 100644 libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs_neg.cc create mode 100644 libstdc++-v3/testsuite/20_util/make_unsigned/requirements/explicit_instantiation.cc create mode 100644 libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs.cc create mode 100644 libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc create mode 100644 libstdc++-v3/testsuite/20_util/tuple/requirements/explicit_instantiation.cc delete mode 100644 libstdc++-v3/testsuite/23_containers/tuple/requirements/explicit_instantiation.cc (limited to 'libstdc++-v3') diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 1aee8b0..48a0494 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,84 @@ +2007-05-03 Benjamin Kosnik + + * include/std/type_traits (enable_if): New. + (conditional): New. + (__decay_selector, decay): New. + (__cv_selector, __match_cv_qualifiers): New. + (__make_unsigned, __make_unsigned_selector, make_unsigned): New. + (__make_signed, __make_signed_selector, make_signed): New. + (has_trivial_constructor): ... to has_trivial_default_constructor. + (has_nothrow_constructor): ... to has_nothrow_default_constructor. + (has_trivial_copy): ... to has_trivial_copy_constructor. + (has_nothrow_copy): ... to has_nothrow_copy_constructor. + + * include/tr1/type_traits_fwd: Move to... + * include/tr1/type_traitsfwd: ... this, consistency with + ios/string/locale forward headers. + * include/tr1/type_traits: Adjust include. + * include/Makefile.am (tr1_headers): Change type_traits_fwd.h to + type_traitsfwd.h. + * include/Makefile.in: Regenerate. + + * testsuite/23_containers/tuple: Move... + * testsuite/20_util/tuple:... here. + + * testsuite/20_util/conditional: New. + * testsuite/20_util/conditional/requirements: Same. + * testsuite/20_util/conditional/requirements/ + explicit_instantiation.cc: Same. + * testsuite/20_util/conditional/requirements/typedefs.cc: Same. + * testsuite/20_util/decay: Same. + * testsuite/20_util/decay/requirements: Same. + * testsuite/20_util/decay/requirements/explicit_instantiation.cc: Same. + * testsuite/20_util/decay/requirements/typedefs.cc: Same. + * testsuite/20_util/enable_if: Same. + * testsuite/20_util/enable_if/requirements: Same. + * testsuite/20_util/enable_if/requirements/ + explicit_instantiation.cc: Same. + * testsuite/20_util/enable_if/requirements/typedefs.cc: Same. + * testsuite/20_util/enable_if/requirements/typedefs_neg.cc: Same. + * testsuite/20_util/has_nothrow_copy_constructor: Same. + * testsuite/20_util/has_nothrow_copy_constructor/requirements: Same. + * testsuite/20_util/has_nothrow_copy_constructor/requirements/ + explicit_instantiation.cc: Same. + * testsuite/20_util/has_nothrow_copy_constructor/requirements/ + typedefs.cc: Same. + * testsuite/20_util/has_nothrow_copy_constructor/value.cc: Same. + * testsuite/20_util/has_nothrow_default_constructor: Same. + * testsuite/20_util/has_nothrow_default_constructor/requirements: Same. + * testsuite/20_util/has_nothrow_default_constructor/requirements/ + explicit_instantiation.cc: Same. + * testsuite/20_util/has_nothrow_default_constructor/requirements/ + typedefs.cc: Same. + * testsuite/20_util/has_nothrow_default_constructor/value.cc: Same. + * testsuite/20_util/has_trivial_copy_constructor: Same. + * testsuite/20_util/has_trivial_copy_constructor/requirements: Same. + * testsuite/20_util/has_trivial_copy_constructor/requirements/ + explicit_instantiation.cc: Same. + * testsuite/20_util/has_trivial_copy_constructor/requirements/ + typedefs.cc: Same. + * testsuite/20_util/has_trivial_copy_constructor/value.cc: Same. + * testsuite/20_util/has_trivial_default_constructor: Same. + * testsuite/20_util/has_trivial_default_constructor/requirements: Same. + * testsuite/20_util/has_trivial_default_constructor/requirements/ + explicit_instantiation.cc: Same. + * testsuite/20_util/has_trivial_default_constructor/requirements/ + typedefs.cc: Same. + * testsuite/20_util/has_trivial_default_constructor/value.cc: Same. + * testsuite/20_util/headers/type_traits/types_std_c++0x_neg.cc: Same. + * testsuite/20_util/make_signed: Same. + * testsuite/20_util/make_signed/requirements: Same. + * testsuite/20_util/make_signed/requirements/ + explicit_instantiation.cc: Same. + * testsuite/20_util/make_signed/requirements/typedefs.cc: Same. + * testsuite/20_util/make_signed/requirements/typedefs_neg.cc: Same. + * testsuite/20_util/make_unsigned: Same. + * testsuite/20_util/make_unsigned/requirements: Same. + * testsuite/20_util/make_unsigned/requirements/ + explicit_instantiation.cc: Same. + * testsuite/20_util/make_unsigned/requirements/typedefs.cc: Same. + * testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc: Same. + 2007-05-02 Paolo Carlini PR libstdc++/31777 diff --git a/libstdc++-v3/include/Makefile.am b/libstdc++-v3/include/Makefile.am index 75be19a..ea27464 100644 --- a/libstdc++-v3/include/Makefile.am +++ b/libstdc++-v3/include/Makefile.am @@ -592,7 +592,7 @@ tr1_headers = \ ${tr1_srcdir}/tgmath.h \ ${tr1_srcdir}/tuple \ ${tr1_srcdir}/type_traits \ - ${tr1_srcdir}/type_traits_fwd.h \ + ${tr1_srcdir}/type_traitsfwd.h \ ${tr1_srcdir}/unordered_set \ ${tr1_srcdir}/unordered_map \ ${tr1_srcdir}/utility \ diff --git a/libstdc++-v3/include/Makefile.in b/libstdc++-v3/include/Makefile.in index 5b4ad59..4402d84 100644 --- a/libstdc++-v3/include/Makefile.in +++ b/libstdc++-v3/include/Makefile.in @@ -822,7 +822,7 @@ tr1_headers = \ ${tr1_srcdir}/tgmath.h \ ${tr1_srcdir}/tuple \ ${tr1_srcdir}/type_traits \ - ${tr1_srcdir}/type_traits_fwd.h \ + ${tr1_srcdir}/type_traitsfwd.h \ ${tr1_srcdir}/unordered_set \ ${tr1_srcdir}/unordered_map \ ${tr1_srcdir}/utility \ diff --git a/libstdc++-v3/include/std/type_traits b/libstdc++-v3/include/std/type_traits index 1d83dab..0d7e85e 100644 --- a/libstdc++-v3/include/std/type_traits +++ b/libstdc++-v3/include/std/type_traits @@ -42,5 +42,305 @@ # include #endif +_GLIBCXX_BEGIN_NAMESPACE(std) + + // Define a nested type if some predicate holds. + template + struct enable_if + { }; + + template + struct enable_if + { typedef _Tp type; }; + + + // Like a conditional expression, but for types. If true, first, if + // false, second. + template + struct conditional + { typedef _Iftrue type; }; + + template + struct conditional + { typedef _Iffalse type; }; + + + // Decay trait for arrays and functions, used for perfect forwarding + // in make_pair, make_tuple, etc. + template::value, + bool _IsFunction = is_function<_Up>::value> + struct __decay_selector; + + template + struct __decay_selector<_Up, false, false> + { typedef _Up __type; }; + + template + struct __decay_selector<_Up, true, false> + { typedef typename remove_extent<_Up>::type* __type; }; + + + template + struct __decay_selector<_Up, false, true> + { typedef typename add_pointer<_Up>::type __type; }; + + template + struct decay + { + private: + typedef typename remove_reference<_Tp>::type __remove_type; + + public: + typedef typename __decay_selector<__remove_type>::__type type; + }; + + + // Utility for constructing identically cv-qualified types. + template + struct __cv_selector; + + template + struct __cv_selector<_Unqualified, false, false> + { typedef _Unqualified __type; }; + + template + struct __cv_selector<_Unqualified, false, true> + { typedef volatile _Unqualified __type; }; + + template + struct __cv_selector<_Unqualified, true, false> + { typedef const _Unqualified __type; }; + + template + struct __cv_selector<_Unqualified, true, true> + { typedef const volatile _Unqualified __type; }; + + template::value, + bool _IsVol = is_volatile<_Qualified>::value> + struct __match_cv_qualifiers + { + private: + typedef __cv_selector<_Unqualified, _IsConst, _IsVol> __match; + + public: + typedef typename __match::__type __type; + }; + + + // Utility for finding the unsigned versions of signed integral types. + template + struct __make_unsigned; + + template<> + struct __make_unsigned + { typedef unsigned char __type; }; + + template<> + struct __make_unsigned + { typedef unsigned char __type; }; + + template<> + struct __make_unsigned + { typedef unsigned wchar_t __type; }; + + template<> + struct __make_unsigned + { typedef unsigned short __type; }; + + template<> + struct __make_unsigned + { typedef unsigned int __type; }; + + template<> + struct __make_unsigned + { typedef unsigned long __type; }; + + template<> + struct __make_unsigned + { typedef unsigned long long __type; }; + + + // Select between integral and enum: not possible to be both. + template::value, + bool _IsUnsigned = is_unsigned<_Tp>::value, + bool _IsEnum = is_enum<_Tp>::value> + struct __make_unsigned_selector; + + template + struct __make_unsigned_selector<_Tp, true, true, false> + { typedef _Tp __type; }; + + template + struct __make_unsigned_selector<_Tp, true, false, false> + { + private: + typedef __make_unsigned::type> __unsignedt; + typedef typename __unsignedt::__type __unsigned_type; + typedef __match_cv_qualifiers<_Tp, __unsigned_type> __cv_unsigned; + + public: + typedef typename __cv_unsigned::__type __type; + }; + + template + struct __make_unsigned_selector<_Tp, false, true, false> + { + private: + // GNU floating point types start with sizeof int. + static const bool __b1 = sizeof(_Tp) <= sizeof(unsigned int); + static const bool __b2 = sizeof(_Tp) <= sizeof(unsigned long); + typedef conditional<__b2, unsigned long, unsigned long long> __cond; + typedef typename __cond::type __cond_type; + typedef unsigned int __ui_type; + + public: + typedef typename conditional<__b1, __ui_type, __cond_type>::type __type; + }; + + template + struct __make_unsigned_selector<_Tp, false, false, true> + { + private: + // GNU enums start with sizeof int. + static const bool __b1 = sizeof(_Tp) <= sizeof(unsigned int); + static const bool __b2 = sizeof(_Tp) <= sizeof(unsigned long); + typedef conditional<__b2, unsigned long, unsigned long long> __cond; + typedef typename __cond::type __cond_type; + typedef unsigned int __ui_type; + + public: + typedef typename conditional<__b1, __ui_type, __cond_type>::type __type; + }; + + // Primary class template. + // Given an integral/enum type, return the corresponding unsigned + // integer type. + template + struct make_unsigned + { typedef typename __make_unsigned_selector<_Tp>::__type type; }; + + // Integral, but don't define. + template<> + struct make_unsigned; + + + // Utility for finding the signed versions of unsigned integral types. + template + struct __make_signed; + + template<> + struct __make_signed + { typedef signed char __type; }; + + template<> + struct __make_signed + { typedef signed char __type; }; + + template<> + struct __make_signed + { typedef signed wchar_t __type; }; + + template<> + struct __make_signed + { typedef signed short __type; }; + + template<> + struct __make_signed + { typedef signed int __type; }; + + template<> + struct __make_signed + { typedef signed long __type; }; + + template<> + struct __make_signed + { typedef signed long long __type; }; + + + // Select between arithmetic and enum: not possible to be both. + template::value, + bool _IsSigned = is_signed<_Tp>::value, + bool _IsEnum = is_enum<_Tp>::value> + struct __make_signed_selector; + + template + struct __make_signed_selector<_Tp, true, true, false> + { typedef _Tp __type; }; + + template + struct __make_signed_selector<_Tp, true, false, false> + { + private: + typedef __make_signed::type> __signedt; + typedef typename __signedt::__type __signed_type; + typedef __match_cv_qualifiers<_Tp, __signed_type> __cv_signed; + + public: + typedef typename __cv_signed::__type __type; + }; + + template + struct __make_signed_selector<_Tp, false, true, false> + { + // GNU floating point types start with sizeof int. + static const bool __b1 = sizeof(_Tp) <= sizeof(signed int); + static const bool __b2 = sizeof(_Tp) <= sizeof(signed long); + typedef conditional<__b2, signed long, signed long long> __cond; + typedef typename __cond::type __cond_type; + typedef unsigned int __i_type; + + public: + typedef typename conditional<__b1, __i_type, __cond_type>::type __type; + }; + + template + struct __make_signed_selector<_Tp, false, false, true> + { + private: + // GNU enums start with sizeof int. + static const bool __b1 = sizeof(_Tp) <= sizeof(signed int); + static const bool __b2 = sizeof(_Tp) <= sizeof(signed long); + typedef conditional<__b2, signed long, signed long long> __cond; + typedef typename __cond::type __cond_type; + typedef int __i_type; + + public: + typedef typename conditional<__b1, __i_type, __cond_type>::type __type; + }; + + // Primary class template. + // Given an integral/enum type, return the corresponding signed + // integer type. + template + struct make_signed + { typedef typename __make_signed_selector<_Tp>::__type type; }; + + // Integral, but don't define. + template<> + struct make_signed; + + + template + struct has_nothrow_default_constructor + : public integral_constant::value> { }; + + template + struct has_nothrow_copy_constructor + : public integral_constant::value> { }; + + template + struct has_trivial_default_constructor + : public integral_constant::value> { }; + + template + struct has_trivial_copy_constructor + : public integral_constant::value> { }; + +_GLIBCXX_END_NAMESPACE + #endif diff --git a/libstdc++-v3/include/tr1/type_traits b/libstdc++-v3/include/tr1/type_traits index c824ef7..41edc3a 100644 --- a/libstdc++-v3/include/tr1/type_traits +++ b/libstdc++-v3/include/tr1/type_traits @@ -37,7 +37,7 @@ #pragma GCC system_header #include -#include +#include // namespace std::tr1 namespace std diff --git a/libstdc++-v3/include/tr1/type_traits_fwd.h b/libstdc++-v3/include/tr1/type_traits_fwd.h deleted file mode 100644 index c6e80a3..0000000 --- a/libstdc++-v3/include/tr1/type_traits_fwd.h +++ /dev/null @@ -1,222 +0,0 @@ -// TR1 type_traits -*- C++ -*- - -// Copyright (C) 2004, 2005, 2006, 2007 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 2, 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 COPYING. If not, write to the Free -// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, -// USA. - -// As a special exception, you may use this file as part of a free software -// library without restriction. Specifically, if other files instantiate -// templates or use macros or inline functions from this file, or you compile -// this file and link it with other files to produce an executable, this -// file does not by itself cause the resulting executable to be covered by -// the GNU General Public License. This exception does not however -// invalidate any other reasons why the executable file might be covered by -// the GNU General Public License. - -/** @file tr1/type_traits_fwd.h - * This is an internal header file, included by other library headers. - * You should not attempt to use it directly. - */ - -#ifndef _TYPE_TRAITS_FWD_H -#define _TYPE_TRAITS_FWD_H 1 - -#include - -// namespace std::tr1 -namespace std -{ -_GLIBCXX_BEGIN_NAMESPACE(_GLIBCXX_TR1) - - /// @brief helper classes [4.3]. - template - struct integral_constant; - typedef integral_constant true_type; - typedef integral_constant false_type; - - /// @brief primary type categories [4.5.1]. - template - struct is_void; - - template - struct is_integral; - - template - struct is_floating_point; - - template - struct is_array; - - template - struct is_pointer; - - template - struct is_reference; - - template - struct is_member_object_pointer; - - template - struct is_member_function_pointer; - - template - struct is_enum; - - template - struct is_union; - - template - struct is_class; - - template - struct is_function; - - /// @brief composite type traits [4.5.2]. - template - struct is_arithmetic; - - template - struct is_fundamental; - - template - struct is_object; - - template - struct is_scalar; - - template - struct is_compound; - - template - struct is_member_pointer; - - /// @brief type properties [4.5.3]. - template - struct is_const; - - template - struct is_volatile; - - template - struct is_pod; - - template - struct is_empty; - - template - struct is_polymorphic; - - template - struct is_abstract; - - template - struct has_trivial_constructor; - - template - struct has_trivial_copy; - - template - struct has_trivial_assign; - - template - struct has_trivial_destructor; - - template - struct has_nothrow_constructor; - - template - struct has_nothrow_copy; - - template - struct has_nothrow_assign; - - template - struct has_virtual_destructor; - - template - struct is_signed; - - template - struct is_unsigned; - - template - struct alignment_of; - - template - struct rank; - - template - struct extent; - - /// @brief relationships between types [4.6]. - template - struct is_same; - - template - struct is_convertible; - - template - struct is_base_of; - - /// @brief const-volatile modifications [4.7.1]. - template - struct remove_const; - - template - struct remove_volatile; - - template - struct remove_cv; - - template - struct add_const; - - template - struct add_volatile; - - template - struct add_cv; - - /// @brief reference modifications [4.7.2]. - template - struct remove_reference; - - template - struct add_reference; - - /// @brief array modifications [4.7.3]. - template - struct remove_extent; - - template - struct remove_all_extents; - - /// @brief pointer modifications [4.7.4]. - template - struct remove_pointer; - - template - struct add_pointer; - - /// @brief other transformations [4.8]. - template - struct aligned_storage; - -_GLIBCXX_END_NAMESPACE -} - -#endif diff --git a/libstdc++-v3/include/tr1/type_traitsfwd.h b/libstdc++-v3/include/tr1/type_traitsfwd.h new file mode 100644 index 0000000..4978014 --- /dev/null +++ b/libstdc++-v3/include/tr1/type_traitsfwd.h @@ -0,0 +1,222 @@ +// TR1 type_traits -*- C++ -*- + +// Copyright (C) 2004, 2005, 2006, 2007 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +/** @file tr1/type_traitsfwd.h + * This is an internal header file, included by other library headers. + * You should not attempt to use it directly. + */ + +#ifndef _TYPE_TRAITSFWD_H +#define _TYPE_TRAIT_FWD_H 1 + +#include + +// namespace std::tr1 +namespace std +{ +_GLIBCXX_BEGIN_NAMESPACE(_GLIBCXX_TR1) + + /// @brief helper classes [4.3]. + template + struct integral_constant; + typedef integral_constant true_type; + typedef integral_constant false_type; + + /// @brief primary type categories [4.5.1]. + template + struct is_void; + + template + struct is_integral; + + template + struct is_floating_point; + + template + struct is_array; + + template + struct is_pointer; + + template + struct is_reference; + + template + struct is_member_object_pointer; + + template + struct is_member_function_pointer; + + template + struct is_enum; + + template + struct is_union; + + template + struct is_class; + + template + struct is_function; + + /// @brief composite type traits [4.5.2]. + template + struct is_arithmetic; + + template + struct is_fundamental; + + template + struct is_object; + + template + struct is_scalar; + + template + struct is_compound; + + template + struct is_member_pointer; + + /// @brief type properties [4.5.3]. + template + struct is_const; + + template + struct is_volatile; + + template + struct is_pod; + + template + struct is_empty; + + template + struct is_polymorphic; + + template + struct is_abstract; + + template + struct has_trivial_constructor; + + template + struct has_trivial_copy; + + template + struct has_trivial_assign; + + template + struct has_trivial_destructor; + + template + struct has_nothrow_constructor; + + template + struct has_nothrow_copy; + + template + struct has_nothrow_assign; + + template + struct has_virtual_destructor; + + template + struct is_signed; + + template + struct is_unsigned; + + template + struct alignment_of; + + template + struct rank; + + template + struct extent; + + /// @brief relationships between types [4.6]. + template + struct is_same; + + template + struct is_convertible; + + template + struct is_base_of; + + /// @brief const-volatile modifications [4.7.1]. + template + struct remove_const; + + template + struct remove_volatile; + + template + struct remove_cv; + + template + struct add_const; + + template + struct add_volatile; + + template + struct add_cv; + + /// @brief reference modifications [4.7.2]. + template + struct remove_reference; + + template + struct add_reference; + + /// @brief array modifications [4.7.3]. + template + struct remove_extent; + + template + struct remove_all_extents; + + /// @brief pointer modifications [4.7.4]. + template + struct remove_pointer; + + template + struct add_pointer; + + /// @brief other transformations [4.8]. + template + struct aligned_storage; + +_GLIBCXX_END_NAMESPACE +} + +#endif diff --git a/libstdc++-v3/testsuite/20_util/conditional/requirements/explicit_instantiation.cc b/libstdc++-v3/testsuite/20_util/conditional/requirements/explicit_instantiation.cc new file mode 100644 index 0000000..079d366 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/conditional/requirements/explicit_instantiation.cc @@ -0,0 +1,41 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// 2007-05-02 Benjamin Kosnik + +// Copyright (C) 2007 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// NB: This file is for testing type_traits with NO OTHER INCLUDES. + +#include + +namespace std +{ + typedef short test_type; + template struct conditional; +} diff --git a/libstdc++-v3/testsuite/20_util/conditional/requirements/typedefs.cc b/libstdc++-v3/testsuite/20_util/conditional/requirements/typedefs.cc new file mode 100644 index 0000000..980cd6d --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/conditional/requirements/typedefs.cc @@ -0,0 +1,42 @@ +// { dg-options "-std=gnu++0x" } + +// 2007-05-02 Benjamin Kosnik +// +// Copyright (C) 2007 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +#include +#include + +void test01() +{ + bool test __attribute__((unused)) = true; + using std::conditional; + + typedef conditional::type test1_type; + VERIFY( (std::is_same::value) ); + + typedef conditional::type test2_type; + VERIFY( (std::is_same::value) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/decay/requirements/explicit_instantiation.cc b/libstdc++-v3/testsuite/20_util/decay/requirements/explicit_instantiation.cc new file mode 100644 index 0000000..d804d11 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/decay/requirements/explicit_instantiation.cc @@ -0,0 +1,41 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// 2007-05-02 Benjamin Kosnik + +// Copyright (C) 2007 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// NB: This file is for testing type_traits with NO OTHER INCLUDES. + +#include + +namespace std +{ + typedef short test_type; + template struct decay; +} diff --git a/libstdc++-v3/testsuite/20_util/decay/requirements/typedefs.cc b/libstdc++-v3/testsuite/20_util/decay/requirements/typedefs.cc new file mode 100644 index 0000000..162ddd2 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/decay/requirements/typedefs.cc @@ -0,0 +1,52 @@ +// { dg-options "-std=gnu++0x" } + +// 2007-05-03 Benjamin Kosnik +// +// Copyright (C) 2007 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +#include +#include +#include + +void test01() +{ + bool test __attribute__((unused)) = true; + using std::decay; + using std::is_same; + + // Positive tests. + typedef decay::type test1_type; + VERIFY( (is_same::value) ); + + typedef decay::type test2_type; + VERIFY( (is_same::value) ); + + typedef decay::type test3_type; + VERIFY( (is_same::type*>::value) ); + + typedef void (fn_type) (); + typedef decay::type test4_type; + VERIFY( (is_same::type>::value) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/enable_if/requirements/explicit_instantiation.cc b/libstdc++-v3/testsuite/20_util/enable_if/requirements/explicit_instantiation.cc new file mode 100644 index 0000000..f236eab --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/enable_if/requirements/explicit_instantiation.cc @@ -0,0 +1,41 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// 2007-05-02 Benjamin Kosnik + +// Copyright (C) 2007 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// NB: This file is for testing type_traits with NO OTHER INCLUDES. + +#include + +namespace std +{ + typedef short test_type; + template struct enable_if; +} diff --git a/libstdc++-v3/testsuite/20_util/enable_if/requirements/typedefs.cc b/libstdc++-v3/testsuite/20_util/enable_if/requirements/typedefs.cc new file mode 100644 index 0000000..34deb21 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/enable_if/requirements/typedefs.cc @@ -0,0 +1,33 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// 2007-05-02 Benjamin Kosnik +// +// Copyright (C) 2007 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +#include + +void test01() +{ + bool test __attribute__((unused)) = true; + using std::enable_if; + + // Positive tests. + typedef enable_if::type test1_type; +} diff --git a/libstdc++-v3/testsuite/20_util/enable_if/requirements/typedefs_neg.cc b/libstdc++-v3/testsuite/20_util/enable_if/requirements/typedefs_neg.cc new file mode 100644 index 0000000..daff6ad --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/enable_if/requirements/typedefs_neg.cc @@ -0,0 +1,36 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// 2007-05-02 Benjamin Kosnik +// +// Copyright (C) 2007 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +#include +#include + +void test01() +{ + bool test __attribute__((unused)) = true; + using std::enable_if; + + // Negative tests. + typedef enable_if::type test2_type; +} + +// { dg-error "does not name a type" "" { target *-*-* } 33 } diff --git a/libstdc++-v3/testsuite/20_util/has_nothrow_copy_constructor/requirements/explicit_instantiation.cc b/libstdc++-v3/testsuite/20_util/has_nothrow_copy_constructor/requirements/explicit_instantiation.cc new file mode 100644 index 0000000..dff484e --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/has_nothrow_copy_constructor/requirements/explicit_instantiation.cc @@ -0,0 +1,40 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } +// 2007-04-30 Benjamin Kosnik + +// Copyright (C) 2007 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// NB: This file is for testing type_traits with NO OTHER INCLUDES. + +#include + +namespace std +{ + typedef short test_type; + template struct has_nothrow_copy_constructor; +} diff --git a/libstdc++-v3/testsuite/20_util/has_nothrow_copy_constructor/requirements/typedefs.cc b/libstdc++-v3/testsuite/20_util/has_nothrow_copy_constructor/requirements/typedefs.cc new file mode 100644 index 0000000..02c30d9 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/has_nothrow_copy_constructor/requirements/typedefs.cc @@ -0,0 +1,37 @@ +// { dg-options "-std=gnu++0x" } +// 2004-12-30 Paolo Carlini +// +// Copyright (C) 2004, 2007 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// +// NB: This file is for testing type_traits with NO OTHER INCLUDES. + +#include + +// { dg-do compile } + +void test01() +{ + // Check for required typedefs + typedef std::has_nothrow_copy_constructor 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/has_nothrow_copy_constructor/value.cc b/libstdc++-v3/testsuite/20_util/has_nothrow_copy_constructor/value.cc new file mode 100644 index 0000000..ac79317 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/has_nothrow_copy_constructor/value.cc @@ -0,0 +1,54 @@ +// { dg-options "-std=gnu++0x" } +// 2004-12-30 Paolo Carlini +// +// Copyright (C) 2004, 2005, 2007 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +#include +#include +#include + +void test01() +{ + bool test __attribute__((unused)) = true; + using std::has_nothrow_copy_constructor; + 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)) ); + 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)) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/has_nothrow_default_constructor/requirements/explicit_instantiation.cc b/libstdc++-v3/testsuite/20_util/has_nothrow_default_constructor/requirements/explicit_instantiation.cc new file mode 100644 index 0000000..e56d709 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/has_nothrow_default_constructor/requirements/explicit_instantiation.cc @@ -0,0 +1,40 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } +// 2007-04-30 Benjamin Kosnik + +// Copyright (C) 2007 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// NB: This file is for testing type_traits with NO OTHER INCLUDES. + +#include + +namespace std +{ + typedef short test_type; + template struct has_nothrow_default_constructor; +} diff --git a/libstdc++-v3/testsuite/20_util/has_nothrow_default_constructor/requirements/typedefs.cc b/libstdc++-v3/testsuite/20_util/has_nothrow_default_constructor/requirements/typedefs.cc new file mode 100644 index 0000000..6eeb6f0 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/has_nothrow_default_constructor/requirements/typedefs.cc @@ -0,0 +1,37 @@ +// { dg-options "-std=gnu++0x" } +// 2004-12-29 Paolo Carlini +// +// Copyright (C) 2004, 2007 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// +// NB: This file is for testing type_traits with NO OTHER INCLUDES. + +#include + +// { dg-do compile } + +void test01() +{ + // Check for required typedefs + typedef std::has_nothrow_default_constructor 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/has_nothrow_default_constructor/value.cc b/libstdc++-v3/testsuite/20_util/has_nothrow_default_constructor/value.cc new file mode 100644 index 0000000..fccbcf7 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/has_nothrow_default_constructor/value.cc @@ -0,0 +1,59 @@ +// { dg-options "-std=gnu++0x" } +// 2004-12-29 Paolo Carlini +// +// Copyright (C) 2004, 2005, 2006, 2007 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// 4.5.3 Type properties + +#include +#include +#include + +void test01() +{ + bool test __attribute__((unused)) = true; + using std::has_nothrow_default_constructor; + 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)) ); + 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)) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/has_trivial_copy_constructor/requirements/explicit_instantiation.cc b/libstdc++-v3/testsuite/20_util/has_trivial_copy_constructor/requirements/explicit_instantiation.cc new file mode 100644 index 0000000..a6bb87d --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/has_trivial_copy_constructor/requirements/explicit_instantiation.cc @@ -0,0 +1,40 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } +// 2007-04-30 Benjamin Kosnik + +// Copyright (C) 2007 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// NB: This file is for testing type_traits with NO OTHER INCLUDES. + +#include + +namespace std +{ + typedef short test_type; + template struct has_trivial_copy_constructor; +} diff --git a/libstdc++-v3/testsuite/20_util/has_trivial_copy_constructor/requirements/typedefs.cc b/libstdc++-v3/testsuite/20_util/has_trivial_copy_constructor/requirements/typedefs.cc new file mode 100644 index 0000000..7b49ff3 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/has_trivial_copy_constructor/requirements/typedefs.cc @@ -0,0 +1,37 @@ +// { dg-options "-std=gnu++0x" } +// 2004-12-30 Paolo Carlini +// +// Copyright (C) 2004, 2007 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// +// NB: This file is for testing type_traits with NO OTHER INCLUDES. + +#include + +// { dg-do compile } + +void test01() +{ + // Check for required typedefs + typedef std::has_trivial_copy_constructor 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/has_trivial_copy_constructor/value.cc b/libstdc++-v3/testsuite/20_util/has_trivial_copy_constructor/value.cc new file mode 100644 index 0000000..2ea418a --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/has_trivial_copy_constructor/value.cc @@ -0,0 +1,56 @@ +// { dg-options "-std=gnu++0x" } +// 2004-12-30 Paolo Carlini +// +// Copyright (C) 2004, 2005, 2007 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// 4.5.3 Type properties + +#include +#include +#include + +void test01() +{ + bool test __attribute__((unused)) = true; + using std::has_trivial_copy_constructor; + 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)) ); + 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)) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/has_trivial_default_constructor/requirements/explicit_instantiation.cc b/libstdc++-v3/testsuite/20_util/has_trivial_default_constructor/requirements/explicit_instantiation.cc new file mode 100644 index 0000000..03b3050 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/has_trivial_default_constructor/requirements/explicit_instantiation.cc @@ -0,0 +1,40 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } +// 2007-04-30 Benjamin Kosnik + +// Copyright (C) 2007 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// NB: This file is for testing type_traits with NO OTHER INCLUDES. + +#include + +namespace std +{ + typedef short test_type; + template struct has_trivial_default_constructor; +} diff --git a/libstdc++-v3/testsuite/20_util/has_trivial_default_constructor/requirements/typedefs.cc b/libstdc++-v3/testsuite/20_util/has_trivial_default_constructor/requirements/typedefs.cc new file mode 100644 index 0000000..af8e7265 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/has_trivial_default_constructor/requirements/typedefs.cc @@ -0,0 +1,37 @@ +// { dg-options "-std=gnu++0x" } +// 2004-12-26 Paolo Carlini +// +// Copyright (C) 2004, 2007 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// +// NB: This file is for testing type_traits with NO OTHER INCLUDES. + +#include + +// { dg-do compile } + +void test01() +{ + // Check for required typedefs + typedef std::has_trivial_default_constructor 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/has_trivial_default_constructor/value.cc b/libstdc++-v3/testsuite/20_util/has_trivial_default_constructor/value.cc new file mode 100644 index 0000000..fae5ace9 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/has_trivial_default_constructor/value.cc @@ -0,0 +1,59 @@ +// { dg-options "-std=gnu++0x" } +// 2004-12-26 Paolo Carlini +// +// Copyright (C) 2004, 2005, 2006, 2007 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// 4.5.3 Type properties + +#include +#include +#include + +void test01() +{ + bool test __attribute__((unused)) = true; + using std::has_trivial_default_constructor; + 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)) ); + 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)) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/headers/type_traits/types_std_c++0x_neg.cc b/libstdc++-v3/testsuite/20_util/headers/type_traits/types_std_c++0x_neg.cc new file mode 100644 index 0000000..37c5a03 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/headers/type_traits/types_std_c++0x_neg.cc @@ -0,0 +1,37 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2007 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +#include + +namespace gnu +{ + // C++0x changes from TR1. + using std::has_trivial_constructor; + using std::has_nothrow_constructor; + using std::has_trivial_copy; + using std::has_nothrow_copy; +} + +// { dg-error "has not been declared" "" { target *-*-* } 27 } +// { dg-error "has not been declared" "" { target *-*-* } 28 } +// { dg-error "has not been declared" "" { target *-*-* } 29 } +// { dg-error "has not been declared" "" { target *-*-* } 30 } + diff --git a/libstdc++-v3/testsuite/20_util/make_signed/requirements/explicit_instantiation.cc b/libstdc++-v3/testsuite/20_util/make_signed/requirements/explicit_instantiation.cc new file mode 100644 index 0000000..ca0ed88 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/make_signed/requirements/explicit_instantiation.cc @@ -0,0 +1,40 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } +// 2007-04-30 Benjamin Kosnik + +// Copyright (C) 2007 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// NB: This file is for testing type_traits with NO OTHER INCLUDES. + +#include + +namespace std +{ + typedef short test_type; + template struct make_signed; +} diff --git a/libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs.cc b/libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs.cc new file mode 100644 index 0000000..826e47e --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs.cc @@ -0,0 +1,68 @@ +// { dg-options "-std=gnu++0x" } + +// 2007-05-03 Benjamin Kosnik +// +// Copyright (C) 2007 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +#include +#include + +enum test_enum { first_selection }; + +void test01() +{ + bool test __attribute__((unused)) = true; + using std::make_signed; + using std::is_same; + + // Positive tests. + typedef make_signed::type test2_type; + VERIFY( (is_same::value) ); + + typedef make_signed::type test21c_type; + VERIFY( (is_same::value) ); + + typedef make_signed::type test21v_type; + VERIFY( (is_same::value) ); + + typedef make_signed::type test21cv_type; + VERIFY( (is_same::value) ); + + typedef make_signed::type test22_type; + VERIFY( (is_same::value) ); + + typedef make_signed::type test23_type; + VERIFY( (is_same::value) ); + +#if 0 + // XXX + // When is_signed works for floating points types this should pass + typedef make_signed::type test24_type; + VERIFY( (is_same::value) ); +#endif + + typedef make_signed::type test25_type; + VERIFY( (is_same::value) ); +} + +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 new file mode 100644 index 0000000..aa94f2a --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs_neg.cc @@ -0,0 +1,53 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// 2007-05-03 Benjamin Kosnik +// +// Copyright (C) 2007 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +#include +#include + +enum test_enum { first_selection }; + +void test01() +{ + using std::make_signed; + + // Negative tests. + typedef make_signed::type test1_type; + + typedef make_signed<__gnu_test::pod_uint>::type test2_type; + + typedef make_signed::type test3_type; + + typedef void (fn_type) (); + typedef make_signed::type test4_type; +} + +// { dg-error "does not name a type" "" { target *-*-* } 34 } +// { dg-error "instantiated from here" "" { target *-*-* } 36 } +// { dg-error "instantiated from here" "" { target *-*-* } 38 } +// { dg-error "instantiated from here" "" { target *-*-* } 41 } + +// { dg-error "invalid use of incomplete type" "" { target *-*-* } 320 } +// { dg-error "declaration of" "" { target *-*-* } 268 } + +// { dg-excess-errors "At global scope" } +// { dg-excess-errors "In instantiation of" } diff --git a/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/explicit_instantiation.cc b/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/explicit_instantiation.cc new file mode 100644 index 0000000..bc836a7 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/explicit_instantiation.cc @@ -0,0 +1,40 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } +// 2007-04-30 Benjamin Kosnik + +// Copyright (C) 2007 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// NB: This file is for testing type_traits with NO OTHER INCLUDES. + +#include + +namespace std +{ + typedef short test_type; + template struct make_unsigned; +} diff --git a/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs.cc b/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs.cc new file mode 100644 index 0000000..b09d3e9 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs.cc @@ -0,0 +1,68 @@ +// { dg-options "-std=gnu++0x" } + +// 2007-05-03 Benjamin Kosnik +// +// Copyright (C) 2007 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +#include +#include + +enum test_enum { first_selection }; + +void test01() +{ + bool test __attribute__((unused)) = true; + using std::make_unsigned; + using std::is_same; + + // Positive tests. + typedef make_unsigned::type test2_type; + VERIFY( (is_same::value) ); + + typedef make_unsigned::type test21c_type; + VERIFY( (is_same::value) ); + + typedef make_unsigned::type test21v_type; + VERIFY( (is_same::value) ); + + typedef make_unsigned::type test21cv_type; + VERIFY( (is_same::value) ); + + typedef make_unsigned::type test22_type; + VERIFY( (is_same::value) ); + + typedef make_unsigned::type test23_type; + VERIFY( (is_same::value) ); + +#if 0 + // XXX + // When is_unsigned works for floating points types this should pass + typedef make_unsigned::type test24_type; + VERIFY( (is_same::value) ); +#endif + + typedef make_unsigned::type test25_type; + VERIFY( (is_same::value) ); +} + +int main() +{ + test01(); + return 0; +} 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 new file mode 100644 index 0000000..cc07d61 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc @@ -0,0 +1,53 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// 2007-05-03 Benjamin Kosnik +// +// Copyright (C) 2007 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +#include +#include + +enum test_enum { first_selection }; + +void test01() +{ + using std::make_unsigned; + + // Negative tests. + typedef make_unsigned::type test1_type; + + typedef make_unsigned<__gnu_test::pod_uint>::type test2_type; + + typedef make_unsigned::type test3_type; + + typedef void (fn_type) (); + typedef make_unsigned::type test4_type; +} + +// { dg-error "does not name a type" "" { target *-*-* } 34 } +// { dg-error "instantiated from here" "" { target *-*-* } 36 } +// { dg-error "instantiated from here" "" { target *-*-* } 38 } +// { dg-error "instantiated from here" "" { target *-*-* } 41 } + +// { dg-error "invalid use of incomplete type" "" { target *-*-* } 223 } +// { dg-error "declaration of" "" { target *-*-* } 170 } + +// { dg-excess-errors "At global scope" } +// { dg-excess-errors "In instantiation of" } diff --git a/libstdc++-v3/testsuite/20_util/tuple/requirements/explicit_instantiation.cc b/libstdc++-v3/testsuite/20_util/tuple/requirements/explicit_instantiation.cc new file mode 100644 index 0000000..cdead8f --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/tuple/requirements/explicit_instantiation.cc @@ -0,0 +1,33 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2007 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 2, 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 COPYING. If not, write to +// the Free Software Foundation, 51 Franklin Street, Fifth Floor, +// Boston, MA 02110-1301, USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +#include + +template class std::tuple; diff --git a/libstdc++-v3/testsuite/23_containers/tuple/requirements/explicit_instantiation.cc b/libstdc++-v3/testsuite/23_containers/tuple/requirements/explicit_instantiation.cc deleted file mode 100644 index cdead8f..0000000 --- a/libstdc++-v3/testsuite/23_containers/tuple/requirements/explicit_instantiation.cc +++ /dev/null @@ -1,33 +0,0 @@ -// { dg-options "-std=gnu++0x" } -// { dg-do compile } - -// Copyright (C) 2007 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 2, 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 COPYING. If not, write to -// the Free Software Foundation, 51 Franklin Street, Fifth Floor, -// Boston, MA 02110-1301, USA. - -// As a special exception, you may use this file as part of a free software -// library without restriction. Specifically, if other files instantiate -// templates or use macros or inline functions from this file, or you compile -// this file and link it with other files to produce an executable, this -// file does not by itself cause the resulting executable to be covered by -// the GNU General Public License. This exception does not however -// invalidate any other reasons why the executable file might be covered by -// the GNU General Public License. - -#include - -template class std::tuple; -- cgit v1.1