diff options
author | Paolo Carlini <pcarlini@suse.de> | 2007-03-30 19:45:57 +0000 |
---|---|---|
committer | Paolo Carlini <paolo@gcc.gnu.org> | 2007-03-30 19:45:57 +0000 |
commit | cb68ec50055e516ac270a043f772935561b01968 (patch) | |
tree | 63250c95176e6d94178beae6b2735b398dfbfec1 /libstdc++-v3 | |
parent | c7a0240aa55b4f7a2d11d33bd12af7a40f42aa55 (diff) | |
download | gcc-cb68ec50055e516ac270a043f772935561b01968.tar.gz |
re PR c++/26099 (support for type traits is not available)
gcc/
2007-03-30 Paolo Carlini <pcarlini@suse.de>
PR c++/26099
* c-common.h (enum rid): Add RID_HAS_NOTHROW_ASSIGN,
RID_HAS_NOTHROW_CONSTRUCTOR, RID_HAS_NOTHROW_COPY,
RID_HAS_TRIVIAL_ASSIGN, RID_HAS_TRIVIAL_CONSTRUCTOR,
RID_HAS_TRIVIAL_COPY, RID_HAS_TRIVIAL_DESTRUCTOR,
RID_HAS_VIRTUAL_DESTRUCTOR, RID_IS_ABSTRACT, RID_IS_BASE_OF,
RID_IS_CONVERTIBLE_TO, RID_IS_CLASS, RID_IS_EMPTY, RID_IS_ENUM,
RID_IS_POD, RID_IS_POLYMORPHIC, RID_IS_UNION, as
C++ extensions.
* doc/extend.texi (Extensions to the C++ Language): Add Type Traits.
gcc/cp/
2007-03-30 Paolo Carlini <pcarlini@suse.de>
PR c++/26099
* cp-tree.h (enum cp_trait_kind, struct tree_trait_expr,
TRAIT_EXPR_TYPE1, TRAIT_EXPR_TYPE2, TRAIT_EXPR_KIND): Add.
(enum cp_tree_node_structure_enum, union lang_tree_node): Update.
(CLASS_TYPE_NON_UNION_P): Add.
(struct lang_type_class): Add has_complex_dflt.
(TYPE_HAS_COMPLEX_DFLT, TYPE_HAS_TRIVIAL_DFLT): Add.
(locate_copy, locate_ctor, locate_dtor, finish_trait_expr): Declare.
* cp-tree.def: Add TRAIT_EXPR.
* cp-objcp-common.c (cp_tree_size): Add TRAIT_EXPR case.
* lex.c (struct resword): Add __has_nothrow_assign,
__has_nothrow_constructor, __has_nothrow_copy, __has_trivial_assign,
__has_trivial_constructor, __has_trivial_copy,
__has_trivial_destructor, __has_virtual_destructor, __is_abstract,
__is_base_of, __is_class, __is_convertible_to, __is_empty, __is_enum,
__is_pod, __is_polymorphic, __is_union.
* parser.c (cp_parser_primary_expression): Deal with the new RIDs.
(cp_parser_trait_expr): New.
* semantics.c (finish_trait_expr, trait_expr_value
classtype_has_nothrow_copy_or_assign_p): New.
* method.c (locate_copy, locate_ctor, locate_dtor): Do not define
as static.
* decl.c (cp_tree_node_structure): Add TRAIT_EXPR.
* class.c (check_bases, check_field_decl, check_bases_and_members):
Deal with TYPE_HAS_COMPLEX_DFLT (t) too.
* pt.c (uses_template_parms, tsubst_copy_and_build,
value_dependent_expression_p, type_dependent_expression_p): Deal with
TRAIT_EXPR.
* tree.c (cp_walk_subtrees): Deal with TRAIT_EXPR.
gcc/testsuite/
2007-03-30 Paolo Carlini <pcarlini@suse.de>
PR c++/26099
* g++.dg/ext/is_base_of.C: New.
* g++.dg/ext/has_virtual_destructor.C: New.
* g++.dg/ext/is_polymorphic.C: New.
* g++.dg/ext/is_base_of_diagnostic.C: New.
* g++.dg/ext/is_enum.C: New.
* g++.dg/ext/has_nothrow_assign.C: New.
* g++.dg/ext/has_nothrow_constructor.C: New.
* g++.dg/ext/is_empty.C: New.
* g++.dg/ext/has_trivial_copy.C: New.
* g++.dg/ext/has_trivial_assign.C: New.
* g++.dg/ext/is_abstract.C: New.
* g++.dg/ext/is_pod.C: New.
* g++.dg/ext/has_nothrow_copy.C: New.
* g++.dg/ext/is_class.C: New.
* g++.dg/ext/has_trivial_constructor.C: New.
* g++.dg/ext/is_union.C: New.
* g++.dg/ext/has_trivial_destructor.C: New.
* g++.dg/tree-ssa/pr22444.C: Adjust, avoid __is_pod.
* g++.dg/template/crash43.C: Likewise.
libstdc++-v3/
2007-03-30 Paolo Carlini <pcarlini@suse.de>
PR c++/26099
* include/bits/cpp_type_traits.h (struct __is_pod, struct __is_empty):
Remove.
* include/bits/valarray_array.h: Adjust.
* include/bits/allocator.h: Likewise.
* include/bits/stl_tree.h: Likewise.
From-SVN: r123366
Diffstat (limited to 'libstdc++-v3')
-rw-r--r-- | libstdc++-v3/ChangeLog | 9 | ||||
-rw-r--r-- | libstdc++-v3/include/bits/allocator.h | 4 | ||||
-rw-r--r-- | libstdc++-v3/include/bits/cpp_type_traits.h | 47 | ||||
-rw-r--r-- | libstdc++-v3/include/bits/stl_tree.h | 2 | ||||
-rw-r--r-- | libstdc++-v3/include/bits/valarray_array.h | 16 |
5 files changed, 21 insertions, 57 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 7483907ac0d..a6ab09b72fe 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,5 +1,14 @@ 2007-03-30 Paolo Carlini <pcarlini@suse.de> + PR c++/26099 + * include/bits/cpp_type_traits.h (struct __is_pod, struct __is_empty): + Remove. + * include/bits/valarray_array.h: Adjust. + * include/bits/allocator.h: Likewise. + * include/bits/stl_tree.h: Likewise. + +2007-03-30 Paolo Carlini <pcarlini@suse.de> + PR libstdc++/31401 * include/bits/basic_string.tcc (find(const _CharT*, size_type, size_type)): Avoid unsigned overflow. diff --git a/libstdc++-v3/include/bits/allocator.h b/libstdc++-v3/include/bits/allocator.h index 43939c14fa7..94f43ce23f3 100644 --- a/libstdc++-v3/include/bits/allocator.h +++ b/libstdc++-v3/include/bits/allocator.h @@ -1,6 +1,6 @@ // Allocators -*- C++ -*- -// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 +// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007 // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free @@ -132,7 +132,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) #undef __glibcxx_base_allocator // To implement Option 3 of DR 431. - template<typename _Alloc, bool = std::__is_empty<_Alloc>::__value> + template<typename _Alloc, bool = __is_empty(_Alloc)> struct __alloc_swap { static void _S_do_it(_Alloc&, _Alloc&) { } }; diff --git a/libstdc++-v3/include/bits/cpp_type_traits.h b/libstdc++-v3/include/bits/cpp_type_traits.h index ed9a48a704a..f3c71ac1be5 100644 --- a/libstdc++-v3/include/bits/cpp_type_traits.h +++ b/libstdc++-v3/include/bits/cpp_type_traits.h @@ -1,6 +1,6 @@ // The -*- C++ -*- type traits classes for internal use in libstdc++ -// Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006 +// Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free @@ -80,20 +80,6 @@ _GLIBCXX_END_NAMESPACE _GLIBCXX_BEGIN_NAMESPACE(std) -namespace __detail -{ - // NB: g++ can not compile these if declared within the class - // __is_pod itself. - typedef char __one; - typedef char __two[2]; - - template<typename _Tp> - __one __test_type(int _Tp::*); - template<typename _Tp> - __two& __test_type(...); -} // namespace __detail - - struct __true_type { }; struct __false_type { }; @@ -341,37 +327,6 @@ namespace __detail : public __traitor<__is_arithmetic<_Tp>, __is_pointer<_Tp> > { }; - // For the immediate use, the following is a good approximation. - template<typename _Tp> - struct __is_pod - { - enum - { - __value = (sizeof(__detail::__test_type<_Tp>(0)) - != sizeof(__detail::__one)) - }; - }; - - // - // A stripped-down version of std::tr1::is_empty - // - template<typename _Tp> - struct __is_empty - { - private: - template<typename> - struct __first { }; - template<typename _Up> - struct __second - : public _Up { }; - - public: - enum - { - __value = sizeof(__first<_Tp>) == sizeof(__second<_Tp>) - }; - }; - // // For use in std::copy and std::find overloads for streambuf iterators. // diff --git a/libstdc++-v3/include/bits/stl_tree.h b/libstdc++-v3/include/bits/stl_tree.h index 0bb65394718..e80afc808a3 100644 --- a/libstdc++-v3/include/bits/stl_tree.h +++ b/libstdc++-v3/include/bits/stl_tree.h @@ -393,7 +393,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) protected: template<typename _Key_compare, - bool _Is_pod_comparator = std::__is_pod<_Key_compare>::__value> + bool _Is_pod_comparator = __is_pod(_Key_compare)> struct _Rb_tree_impl : public _Node_allocator { _Key_compare _M_key_compare; diff --git a/libstdc++-v3/include/bits/valarray_array.h b/libstdc++-v3/include/bits/valarray_array.h index a40c880ba8d..12a6b5fd419 100644 --- a/libstdc++-v3/include/bits/valarray_array.h +++ b/libstdc++-v3/include/bits/valarray_array.h @@ -1,6 +1,6 @@ // The template and inlines for the -*- C++ -*- internal _Array helper class. -// Copyright (C) 1997, 1998, 1999, 2000, 2003, 2004, 2005, 2006 +// Copyright (C) 1997, 1998, 1999, 2000, 2003, 2004, 2005, 2006, 2007 // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free @@ -98,7 +98,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) inline void __valarray_default_construct(_Tp* __restrict__ __b, _Tp* __restrict__ __e) { - _Array_default_ctor<_Tp, __is_pod<_Tp>::__value>::_S_do_it(__b, __e); + _Array_default_ctor<_Tp, __is_pod(_Tp)>::_S_do_it(__b, __e); } // Turn a raw-memory into an array of _Tp filled with __t @@ -133,7 +133,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) __valarray_fill_construct(_Tp* __restrict__ __b, _Tp* __restrict__ __e, const _Tp __t) { - _Array_init_ctor<_Tp, __is_pod<_Tp>::__value>::_S_do_it(__b, __e, __t); + _Array_init_ctor<_Tp, __is_pod(_Tp)>::_S_do_it(__b, __e, __t); } // @@ -169,7 +169,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) const _Tp* __restrict__ __e, _Tp* __restrict__ __o) { - _Array_copy_ctor<_Tp, __is_pod<_Tp>::__value>::_S_do_it(__b, __e, __o); + _Array_copy_ctor<_Tp, __is_pod(_Tp)>::_S_do_it(__b, __e, __o); } // copy-construct raw array [__o, *) from strided array __a[<__n : __s>] @@ -178,7 +178,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) __valarray_copy_construct (const _Tp* __restrict__ __a, size_t __n, size_t __s, _Tp* __restrict__ __o) { - if (__is_pod<_Tp>::__value) + if (__is_pod(_Tp)) while (__n--) { *__o++ = *__a; @@ -199,7 +199,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) const size_t* __restrict__ __i, _Tp* __restrict__ __o, size_t __n) { - if (__is_pod<_Tp>::__value) + if (__is_pod(_Tp)) while (__n--) *__o++ = __a[*__i++]; else @@ -212,7 +212,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) inline void __valarray_destroy_elements(_Tp* __restrict__ __b, _Tp* __restrict__ __e) { - if (!__is_pod<_Tp>::__value) + if (!__is_pod(_Tp)) while (__b != __e) { __b->~_Tp(); @@ -276,7 +276,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) __valarray_copy(const _Tp* __restrict__ __a, size_t __n, _Tp* __restrict__ __b) { - _Array_copier<_Tp, __is_pod<_Tp>::__value>::_S_do_it(__a, __n, __b); + _Array_copier<_Tp, __is_pod(_Tp)>::_S_do_it(__a, __n, __b); } // Copy strided array __a[<__n : __s>] in plain __b[<__n>] |