+2007-09-17 Paolo Carlini <pcarlini@suse.de>
+
+ * include/tr1_impl/type_traitsfwd.h (aligned_storage): Remove
+ declaration.
+ * include/tr1_impl/type_traits (aligned_storage): Remove.
+ * include/std/type_traits (aligned_storage, __aligned_storage_msa):
+ Add.
+ * include/tr1/type_traits (aligned_storage): Add.
+ * testsuite/20_util/aligned_storage/value.cc: New.
+ * testsuite/20_util/aligned_storage/requirements/
+ explicit_instantiation.cc: Likewise.
+ * testsuite/20_util/make_signed/requirements/typedefs_neg.cc: Adjust
+ dg-error lines.
+ * testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc:
+ Likewise.
+
2007-09-16 Paolo Carlini <pcarlini@suse.de>
Douglas Gregor <doug.gregor@gmail.com>
__is_convertible_helper<_From, _To>::__value>
{ };
+ template<std::size_t _Len>
+ struct __aligned_storage_msa
+ {
+ union __type
+ {
+ unsigned char __data[_Len];
+ struct __attribute__((__aligned__)) { } __align;
+ };
+ };
+
+ template<std::size_t _Len, std::size_t _Align =
+ __alignof__(typename __aligned_storage_msa<_Len>::__type)>
+ struct aligned_storage
+ {
+ union type
+ {
+ unsigned char __data[_Len];
+ struct __attribute__((__aligned__((_Align)))) { } __align;
+ };
+ };
+
// Define a nested type if some predicate holds.
template<bool, typename _Tp = void>
: public __add_reference_helper<_Tp>
{ };
+ /// @brief other transformations [4.8].
+ template<std::size_t _Len, std::size_t _Align>
+ struct aligned_storage
+ {
+ union type
+ {
+ unsigned char __data[_Len];
+ struct __attribute__((__aligned__((_Align)))) { } __align;
+ };
+ };
+
#undef _DEFINE_SPEC_0_HELPER
#undef _DEFINE_SPEC
#undef _DEFINE_SPEC_BODY
struct add_pointer
{ typedef typename remove_reference<_Tp>::type* type; };
- /// @brief other transformations [4.8].
- template<std::size_t _Len, std::size_t _Align>
- struct aligned_storage
- {
- union type
- {
- unsigned char __data[_Len];
- struct __attribute__((__aligned__((_Align)))) { } __aligner;
- };
- };
-
#undef _DEFINE_SPEC_0_HELPER
#undef _DEFINE_SPEC_1_HELPER
#undef _DEFINE_SPEC_2_HELPER
template<typename _Tp>
struct add_pointer;
- /// @brief other transformations [4.8].
- template<std::size_t _Len, std::size_t _Align>
- struct aligned_storage;
-
_GLIBCXX_END_NAMESPACE_TR1
}
--- /dev/null
+// { dg-options "-std=gnu++0x" }
+// { dg-do compile }
+// 2007-09-17 Paolo Carlini <pcarlini@suse.de>
+
+// 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 <type_traits>
+
+namespace std
+{
+ typedef short test_type;
+ template struct aligned_storage<1, alignment_of<test_type>::value>;
+ template struct aligned_storage<2>;
+}
--- /dev/null
+// { dg-options "-std=gnu++0x" }
+// 2007-09-17 Paolo Carlini <pcarlini@suse.de>
+//
+// 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 <type_traits>
+#include <testsuite_hooks.h>
+#include <testsuite_tr1.h>
+
+struct MSAlignType { } __attribute__((__aligned__));
+
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+ using std::aligned_storage;
+ using std::alignment_of;
+ using namespace __gnu_test;
+
+ const std::size_t align_c = alignment_of<char>::value;
+ VERIFY( (sizeof(aligned_storage<4, align_c>::type) >= 4) );
+ VERIFY( (__alignof__(aligned_storage<4, align_c>::type) == align_c) );
+
+ const std::size_t align_s = alignment_of<short>::value;
+ VERIFY( (sizeof(aligned_storage<1, align_s>::type) >= 1) );
+ VERIFY( (__alignof__(aligned_storage<1, align_s>::type) == align_s) );
+
+ const std::size_t align_i = alignment_of<int>::value;
+ VERIFY( (sizeof(aligned_storage<7, align_i>::type) >= 7) );
+ VERIFY( (__alignof__(aligned_storage<7, align_i>::type) == align_i) );
+
+ const std::size_t align_d = alignment_of<double>::value;
+ VERIFY( (sizeof(aligned_storage<2, align_d>::type) >= 2) );
+ VERIFY( (__alignof__(aligned_storage<2, align_d>::type) == align_d) );
+
+ const std::size_t align_ai = alignment_of<int[4]>::value;
+ VERIFY( (sizeof(aligned_storage<20, align_ai>::type) >= 20) );
+ VERIFY( (__alignof__(aligned_storage<20, align_ai>::type) == align_ai) );
+
+ const std::size_t align_ct = alignment_of<ClassType>::value;
+ VERIFY( (sizeof(aligned_storage<11, align_ct>::type) >= 11) );
+ VERIFY( (__alignof__(aligned_storage<11, align_ct>::type) == align_ct) );
+
+ const std::size_t align_msa = alignment_of<MSAlignType>::value;
+ VERIFY( (sizeof(aligned_storage<5>::type) >= 5) );
+ VERIFY( (__alignof__(aligned_storage<5>::type) == align_msa) );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
// { dg-error "instantiated from here" "" { target *-*-* } 41 }
// { dg-error "instantiated from here" "" { target *-*-* } 43 }
-// { dg-error "invalid use of incomplete type" "" { target *-*-* } 490 }
-// { dg-error "declaration of" "" { target *-*-* } 456 }
+// { dg-error "invalid use of incomplete type" "" { target *-*-* } 511 }
+// { dg-error "declaration of" "" { target *-*-* } 477 }
// { dg-excess-errors "At global scope" }
// { dg-excess-errors "In instantiation of" }
// { dg-error "instantiated from here" "" { target *-*-* } 41 }
// { dg-error "instantiated from here" "" { target *-*-* } 43 }
-// { dg-error "invalid use of incomplete type" "" { target *-*-* } 415 }
-// { dg-error "declaration of" "" { target *-*-* } 381 }
+// { dg-error "invalid use of incomplete type" "" { target *-*-* } 436 }
+// { dg-error "declaration of" "" { target *-*-* } 402 }
// { dg-excess-errors "At global scope" }
// { dg-excess-errors "In instantiation of" }