summaryrefslogtreecommitdiff
path: root/libstdc++-v3
diff options
context:
space:
mode:
authorredi <redi@138bc75d-0d04-0410-961f-82ee72b054a4>2012-06-14 22:07:33 +0000
committerredi <redi@138bc75d-0d04-0410-961f-82ee72b054a4>2012-06-14 22:07:33 +0000
commita0020156e7b462934107cc33044f056a1d464eb7 (patch)
tree7c36953de8a28145a886c09f39ecc89ab70643a6 /libstdc++-v3
parente6df5f90c8804a513c8790e1b5288b1398014f85 (diff)
downloadgcc-a0020156e7b462934107cc33044f056a1d464eb7.tar.gz
PR libstdc++/53648
* include/std/tuple (__empty_not_final): Do not use EBO for tuples. * testsuite/20_util/tuple/53648.cc: New. * testsuite/20_util/uses_allocator/cons_neg.cc: Adjust dg-error line number. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@188636 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3')
-rw-r--r--libstdc++-v3/ChangeLog8
-rw-r--r--libstdc++-v3/include/std/tuple13
-rw-r--r--libstdc++-v3/testsuite/20_util/tuple/53648.cc44
-rw-r--r--libstdc++-v3/testsuite/20_util/uses_allocator/cons_neg.cc2
4 files changed, 64 insertions, 3 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index 864d5138635..818e6746fb8 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,5 +1,13 @@
2012-06-14 Jonathan Wakely <jwakely.gcc@gmail.com>
+ PR libstdc++/53648
+ * include/std/tuple (__empty_not_final): Do not use EBO for tuples.
+ * testsuite/20_util/tuple/53648.cc: New.
+ * testsuite/20_util/uses_allocator/cons_neg.cc: Adjust dg-error line
+ number.
+
+2012-06-14 Jonathan Wakely <jwakely.gcc@gmail.com>
+
* doc/xml/manual/status_cxx2011.xml: Correct C++11 status table.
2012-06-01 Jonathan Wakely <jwakely.gcc@gmail.com>
diff --git a/libstdc++-v3/include/std/tuple b/libstdc++-v3/include/std/tuple
index 4d4691f104f..fb9e09fffe8 100644
--- a/libstdc++-v3/include/std/tuple
+++ b/libstdc++-v3/include/std/tuple
@@ -1,6 +1,7 @@
// <tuple> -*- C++ -*-
-// Copyright (C) 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
+// Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012
+// 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
@@ -201,10 +202,18 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
void _M_swap(_Tuple_impl&) noexcept { /* no-op */ }
};
+ template<typename _Tp>
+ struct __is_empty_non_tuple : is_empty<_Tp> { };
+
+ // Using EBO for elements that are tuples causes ambiguous base errors.
+ template<typename _El0, typename... _El>
+ struct __is_empty_non_tuple<tuple<_El0, _El...>> : false_type { };
+
// Use the Empty Base-class Optimization for empty, non-final types.
template<typename _Tp>
using __empty_not_final
- = typename conditional<__is_final(_Tp), false_type, is_empty<_Tp>>::type;
+ = typename conditional<__is_final(_Tp), false_type,
+ __is_empty_non_tuple<_Tp>>::type;
/**
* Recursive tuple implementation. Here we store the @c Head element
diff --git a/libstdc++-v3/testsuite/20_util/tuple/53648.cc b/libstdc++-v3/testsuite/20_util/tuple/53648.cc
new file mode 100644
index 00000000000..5671e444349
--- /dev/null
+++ b/libstdc++-v3/testsuite/20_util/tuple/53648.cc
@@ -0,0 +1,44 @@
+// { dg-options "-std=gnu++0x" }
+// { dg-do compile }
+
+// Copyright (C) 2012 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// libstdc++/53648
+
+#include <tuple>
+#include <type_traits>
+
+using std::tuple;
+
+struct A { };
+
+template class tuple<tuple<>>;
+template class tuple<tuple<tuple<>>>;
+template class tuple<A, tuple<A, tuple<A, tuple<A>>>>;
+template class tuple<tuple<tuple<A, A>, A>, A>;
+
+// Verify the following QoI properties are preserved
+
+static_assert( std::is_empty<tuple<>>::value, "tuple<> is empty" );
+
+static_assert( std::is_empty<tuple<tuple<>>>::value,
+ "tuple<tuple<>> is empty" );
+
+static_assert( sizeof(tuple<char, tuple<>>) == sizeof(char),
+ "tuple<> is eligible for EBO" );
+
diff --git a/libstdc++-v3/testsuite/20_util/uses_allocator/cons_neg.cc b/libstdc++-v3/testsuite/20_util/uses_allocator/cons_neg.cc
index 73a0d0f7029..d81dd35d096 100644
--- a/libstdc++-v3/testsuite/20_util/uses_allocator/cons_neg.cc
+++ b/libstdc++-v3/testsuite/20_util/uses_allocator/cons_neg.cc
@@ -44,4 +44,4 @@ void test01()
tuple<Type> t(allocator_arg, a, 1);
}
-// { dg-error "no matching function" "" { target *-*-* } 112 }
+// { dg-error "no matching function" "" { target *-*-* } 113 }