* [committed] libstdc++: Add missing 'constexpr' to std::tuple [PR102270]
@ 2021-09-16 22:07 Jonathan Wakely
2021-09-17 11:25 ` Jonathan Wakely
0 siblings, 1 reply; 5+ messages in thread
From: Jonathan Wakely @ 2021-09-16 22:07 UTC (permalink / raw)
To: libstdc++, gcc-patches
[-- Attachment #1: Type: text/plain, Size: 356 bytes --]
Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
libstdc++-v3/ChangeLog:
PR libstdc++/102270
* include/std/tuple (_Head_base, _Tuple_impl): Add
_GLIBCXX20_CONSTEXPR to allocator-extended constructors.
(tuple<>::swap(tuple&)): Add _GLIBCXX20_CONSTEXPR.
* testsuite/20_util/tuple/cons/102270.C: New test.
Tested x86_64-linux. Committed to trunk.
[-- Attachment #2: patch.txt --]
[-- Type: text/plain, Size: 6090 bytes --]
commit 734b2c2eedca50d966e22540fc136158c3633393
Author: Jonathan Wakely <jwakely@redhat.com>
Date: Wed Sep 15 21:53:35 2021
libstdc++: Add missing 'constexpr' to std::tuple [PR102270]
Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
libstdc++-v3/ChangeLog:
PR libstdc++/102270
* include/std/tuple (_Head_base, _Tuple_impl): Add
_GLIBCXX20_CONSTEXPR to allocator-extended constructors.
(tuple<>::swap(tuple&)): Add _GLIBCXX20_CONSTEXPR.
* testsuite/20_util/tuple/cons/102270.C: New test.
diff --git a/libstdc++-v3/include/std/tuple b/libstdc++-v3/include/std/tuple
index f082ccb8a3b..6f0dc6346e1 100644
--- a/libstdc++-v3/include/std/tuple
+++ b/libstdc++-v3/include/std/tuple
@@ -95,10 +95,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
: _M_head_impl() { }
template<typename _Alloc>
+ _GLIBCXX20_CONSTEXPR
_Head_base(allocator_arg_t, __uses_alloc1<_Alloc> __a)
: _M_head_impl(allocator_arg, *__a._M_a) { }
template<typename _Alloc>
+ _GLIBCXX20_CONSTEXPR
_Head_base(allocator_arg_t, __uses_alloc2<_Alloc> __a)
: _M_head_impl(*__a._M_a) { }
@@ -108,11 +110,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
: _M_head_impl(std::forward<_UHead>(__uhead)) { }
template<typename _Alloc, typename _UHead>
+ _GLIBCXX20_CONSTEXPR
_Head_base(__uses_alloc1<_Alloc> __a, _UHead&& __uhead)
: _M_head_impl(allocator_arg, *__a._M_a, std::forward<_UHead>(__uhead))
{ }
template<typename _Alloc, typename _UHead>
+ _GLIBCXX20_CONSTEXPR
_Head_base(__uses_alloc2<_Alloc> __a, _UHead&& __uhead)
: _M_head_impl(std::forward<_UHead>(__uhead), *__a._M_a) { }
@@ -142,26 +146,32 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
constexpr _Head_base(_UHead&& __h)
: _Head(std::forward<_UHead>(__h)) { }
+ _GLIBCXX20_CONSTEXPR
_Head_base(allocator_arg_t, __uses_alloc0)
: _Head() { }
template<typename _Alloc>
+ _GLIBCXX20_CONSTEXPR
_Head_base(allocator_arg_t, __uses_alloc1<_Alloc> __a)
: _Head(allocator_arg, *__a._M_a) { }
template<typename _Alloc>
+ _GLIBCXX20_CONSTEXPR
_Head_base(allocator_arg_t, __uses_alloc2<_Alloc> __a)
: _Head(*__a._M_a) { }
template<typename _UHead>
+ _GLIBCXX20_CONSTEXPR
_Head_base(__uses_alloc0, _UHead&& __uhead)
: _Head(std::forward<_UHead>(__uhead)) { }
template<typename _Alloc, typename _UHead>
+ _GLIBCXX20_CONSTEXPR
_Head_base(__uses_alloc1<_Alloc> __a, _UHead&& __uhead)
: _Head(allocator_arg, *__a._M_a, std::forward<_UHead>(__uhead)) { }
template<typename _Alloc, typename _UHead>
+ _GLIBCXX20_CONSTEXPR
_Head_base(__uses_alloc2<_Alloc> __a, _UHead&& __uhead)
: _Head(std::forward<_UHead>(__uhead), *__a._M_a) { }
@@ -194,10 +204,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
: _M_head_impl() { }
template<typename _Alloc>
+ _GLIBCXX20_CONSTEXPR
_Head_base(allocator_arg_t, __uses_alloc1<_Alloc> __a)
: _M_head_impl(allocator_arg, *__a._M_a) { }
template<typename _Alloc>
+ _GLIBCXX20_CONSTEXPR
_Head_base(allocator_arg_t, __uses_alloc2<_Alloc> __a)
: _M_head_impl(*__a._M_a) { }
@@ -207,11 +219,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
: _M_head_impl(std::forward<_UHead>(__uhead)) { }
template<typename _Alloc, typename _UHead>
+ _GLIBCXX20_CONSTEXPR
_Head_base(__uses_alloc1<_Alloc> __a, _UHead&& __uhead)
: _M_head_impl(allocator_arg, *__a._M_a, std::forward<_UHead>(__uhead))
{ }
template<typename _Alloc, typename _UHead>
+ _GLIBCXX20_CONSTEXPR
_Head_base(__uses_alloc2<_Alloc> __a, _UHead&& __uhead)
: _M_head_impl(std::forward<_UHead>(__uhead), *__a._M_a) { }
@@ -467,6 +481,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
{ }
template<typename _Alloc>
+ _GLIBCXX20_CONSTEXPR
_Tuple_impl(allocator_arg_t __tag, const _Alloc& __a,
const _Head& __head)
: _Base(__use_alloc<_Head, _Alloc, const _Head&>(__a), __head)
@@ -955,6 +970,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
class tuple<>
{
public:
+ _GLIBCXX20_CONSTEXPR
void swap(tuple&) noexcept { /* no-op */ }
// We need the default since we're going to define no-op
// allocator constructors.
diff --git a/libstdc++-v3/testsuite/20_util/tuple/cons/102270.C b/libstdc++-v3/testsuite/20_util/tuple/cons/102270.C
new file mode 100644
index 00000000000..998329817c7
--- /dev/null
+++ b/libstdc++-v3/testsuite/20_util/tuple/cons/102270.C
@@ -0,0 +1,61 @@
+// { dg-options "-std=gnu++20" }
+// { dg-do compile { target c++20 } }
+
+#include <tuple>
+
+// PR libstdc++/102270 - std::tuple<>::swap missing constexpr specifier
+
+constexpr bool swap_empty_tuple()
+{
+ std::tuple<> t, u;
+ t.swap(u);
+ return true;
+}
+static_assert( swap_empty_tuple() );
+
+#include <testsuite_allocator.h>
+
+constexpr bool construct_using_allocator()
+{
+ using Alloc = __gnu_test::SimpleAllocator<int>;
+
+ Alloc a;
+ const int i = 0;
+
+ struct X0a {
+ using allocator_type = Alloc;
+ /* not constexpr */ X0a() { }
+ constexpr X0a(allocator_type) { }
+ };
+ std::tuple<X0a> t0a(std::allocator_arg, a);
+ std::tuple<X0a, X0a> t00a(std::allocator_arg, a);
+
+ struct X0b {
+ using allocator_type = Alloc;
+ /* not constexpr */ X0b() { }
+ constexpr X0b(std::allocator_arg_t, allocator_type) { }
+ };
+ std::tuple<X0b> t0b(std::allocator_arg, a);
+ std::tuple<X0b, X0b> t00b(std::allocator_arg, a);
+
+ struct X1a {
+ using allocator_type = Alloc;
+ /* not constexpr */ X1a(int) { }
+ constexpr X1a(int, allocator_type) { }
+ };
+ std::tuple<X1a> t1a(std::allocator_arg, a, 1);
+ std::tuple<X1a, X1a> t11a(std::allocator_arg, a, 1, i);
+
+ struct X1b {
+ using allocator_type = Alloc;
+ /* not constexpr */ X1b(int) { }
+ constexpr X1b(std::allocator_arg_t, allocator_type, int) { }
+ };
+ std::tuple<X1b> t1b(std::allocator_arg, a, 1);
+ std::tuple<X1b, X1b> t11b(std::allocator_arg, a, 1, i);
+
+ std::tuple<X1a, X1a, X1b, X1b> t1a1b(std::allocator_arg, a, 1, i, 1, i);
+
+ return true;
+}
+static_assert( construct_using_allocator() );
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [committed] libstdc++: Add missing 'constexpr' to std::tuple [PR102270]
2021-09-16 22:07 [committed] libstdc++: Add missing 'constexpr' to std::tuple [PR102270] Jonathan Wakely
@ 2021-09-17 11:25 ` Jonathan Wakely
2021-09-17 19:47 ` [committed] libstdc++: Fix last std::tuple constructor missing 'constexpr' [PR102270] Jonathan Wakely
0 siblings, 1 reply; 5+ messages in thread
From: Jonathan Wakely @ 2021-09-17 11:25 UTC (permalink / raw)
To: libstdc++, gcc-patches
On 16/09/21 23:07 +0100, Jonathan Wakely wrote:
>Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
>
>libstdc++-v3/ChangeLog:
>
> PR libstdc++/102270
> * include/std/tuple (_Head_base, _Tuple_impl): Add
> _GLIBCXX20_CONSTEXPR to allocator-extended constructors.
> (tuple<>::swap(tuple&)): Add _GLIBCXX20_CONSTEXPR.
> * testsuite/20_util/tuple/cons/102270.C: New test.
Oops, this test has a .C extension, and so doesn't actually run (and
if I rename it to 102270.cc it fails).
Fix incoming ...
^ permalink raw reply [flat|nested] 5+ messages in thread
* [committed] libstdc++: Fix last std::tuple constructor missing 'constexpr' [PR102270]
2021-09-17 11:25 ` Jonathan Wakely
@ 2021-09-17 19:47 ` Jonathan Wakely
2021-09-17 19:48 ` Jonathan Wakely
0 siblings, 1 reply; 5+ messages in thread
From: Jonathan Wakely @ 2021-09-17 19:47 UTC (permalink / raw)
To: libstdc++, gcc-patches
On 17/09/21 12:25 +0100, Jonathan Wakely wrote:
>On 16/09/21 23:07 +0100, Jonathan Wakely wrote:
>>Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
>>
>>libstdc++-v3/ChangeLog:
>>
>> PR libstdc++/102270
>> * include/std/tuple (_Head_base, _Tuple_impl): Add
>> _GLIBCXX20_CONSTEXPR to allocator-extended constructors.
>> (tuple<>::swap(tuple&)): Add _GLIBCXX20_CONSTEXPR.
>> * testsuite/20_util/tuple/cons/102270.C: New test.
>
>Oops, this test has a .C extension, and so doesn't actually run (and
>if I rename it to 102270.cc it fails).
>
>Fix incoming ...
Fixed at r12-3637.
Tested x86_64-linux. Committed to trunk.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [committed] libstdc++: Fix last std::tuple constructor missing 'constexpr' [PR102270]
2021-09-17 19:47 ` [committed] libstdc++: Fix last std::tuple constructor missing 'constexpr' [PR102270] Jonathan Wakely
@ 2021-09-17 19:48 ` Jonathan Wakely
0 siblings, 0 replies; 5+ messages in thread
From: Jonathan Wakely @ 2021-09-17 19:48 UTC (permalink / raw)
To: libstdc++, gcc-patches
[-- Attachment #1: Type: text/plain, Size: 731 bytes --]
On 17/09/21 20:47 +0100, Jonathan Wakely wrote:
>On 17/09/21 12:25 +0100, Jonathan Wakely wrote:
>>On 16/09/21 23:07 +0100, Jonathan Wakely wrote:
>>>Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
>>>
>>>libstdc++-v3/ChangeLog:
>>>
>>> PR libstdc++/102270
>>> * include/std/tuple (_Head_base, _Tuple_impl): Add
>>> _GLIBCXX20_CONSTEXPR to allocator-extended constructors.
>>> (tuple<>::swap(tuple&)): Add _GLIBCXX20_CONSTEXPR.
>>> * testsuite/20_util/tuple/cons/102270.C: New test.
>>
>>Oops, this test has a .C extension, and so doesn't actually run (and
>>if I rename it to 102270.cc it fails).
>>
>>Fix incoming ...
>
>Fixed at r12-3637.
>
>Tested x86_64-linux. Committed to trunk.
With the patch attached this time ...
[-- Attachment #2: patch.txt --]
[-- Type: text/x-patch, Size: 2448 bytes --]
commit 1fa2c5a695bb962ffcf8abed49f69cdcc59d0e61
Author: Jonathan Wakely <jwakely@redhat.com>
Date: Fri Sep 17 12:27:02 2021
libstdc++: Fix last std::tuple constructor missing 'constexpr' [PR102270]
Also rename the test so it actually runs.
Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
libstdc++-v3/ChangeLog:
PR libstdc++/102270
* include/std/tuple (_Tuple_impl): Add constexpr to constructor
missed in previous patch.
* testsuite/20_util/tuple/cons/102270.C: Moved to...
* testsuite/20_util/tuple/cons/102270.cc: ...here.
* testsuite/util/testsuite_allocator.h (SimpleAllocator): Add
constexpr to constructor so it can be used for C++20 tests.
diff --git a/libstdc++-v3/include/std/tuple b/libstdc++-v3/include/std/tuple
index 6f0dc6346e1..120c80a2b78 100644
--- a/libstdc++-v3/include/std/tuple
+++ b/libstdc++-v3/include/std/tuple
@@ -330,6 +330,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
{ }
template<typename _Alloc>
+ _GLIBCXX20_CONSTEXPR
_Tuple_impl(allocator_arg_t __tag, const _Alloc& __a,
const _Head& __head, const _Tail&... __tail)
: _Inherited(__tag, __a, __tail...),
diff --git a/libstdc++-v3/testsuite/20_util/tuple/cons/102270.C b/libstdc++-v3/testsuite/20_util/tuple/cons/102270.cc
similarity index 95%
rename from libstdc++-v3/testsuite/20_util/tuple/cons/102270.C
rename to libstdc++-v3/testsuite/20_util/tuple/cons/102270.cc
index 998329817c7..5500cacab6d 100644
--- a/libstdc++-v3/testsuite/20_util/tuple/cons/102270.C
+++ b/libstdc++-v3/testsuite/20_util/tuple/cons/102270.cc
@@ -56,6 +56,9 @@ constexpr bool construct_using_allocator()
std::tuple<X1a, X1a, X1b, X1b> t1a1b(std::allocator_arg, a, 1, i, 1, i);
+ const int c = 0;
+ std::tuple<int, int> tii(std::allocator_arg, a, c, c);
+
return true;
}
static_assert( construct_using_allocator() );
diff --git a/libstdc++-v3/testsuite/util/testsuite_allocator.h b/libstdc++-v3/testsuite/util/testsuite_allocator.h
index 1f7912ea6eb..b5b402858a6 100644
--- a/libstdc++-v3/testsuite/util/testsuite_allocator.h
+++ b/libstdc++-v3/testsuite/util/testsuite_allocator.h
@@ -514,7 +514,7 @@ namespace __gnu_test
{
typedef Tp value_type;
- SimpleAllocator() noexcept { }
+ constexpr SimpleAllocator() noexcept { }
template <class T>
SimpleAllocator(const SimpleAllocator<T>&) { }
^ permalink raw reply [flat|nested] 5+ messages in thread
* [committed] libstdc++: Fix last std::tuple constructor missing 'constexpr' [PR102270]
@ 2021-09-17 19:45 Jonathan Wakely
0 siblings, 0 replies; 5+ messages in thread
From: Jonathan Wakely @ 2021-09-17 19:45 UTC (permalink / raw)
To: libstdc++, gcc-patches
[-- Attachment #1: Type: text/plain, Size: 567 bytes --]
Also rename the test so it actually runs.
Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
libstdc++-v3/ChangeLog:
PR libstdc++/102270
* include/std/tuple (_Tuple_impl): Add constexpr to constructor
missed in previous patch.
* testsuite/20_util/tuple/cons/102270.C: Moved to...
* testsuite/20_util/tuple/cons/102270.cc: ...here.
* testsuite/util/testsuite_allocator.h (SimpleAllocator): Add
constexpr to constructor so it can be used for C++20 tests.
Tested powerpc64le-linux. Committed to trunk.
git mailpatch 42eff613d0c10f88dc7a44b14981876401a09981
[-- Attachment #2: patch.txt --]
[-- Type: text/plain, Size: 2448 bytes --]
commit 1fa2c5a695bb962ffcf8abed49f69cdcc59d0e61
Author: Jonathan Wakely <jwakely@redhat.com>
Date: Fri Sep 17 12:27:02 2021
libstdc++: Fix last std::tuple constructor missing 'constexpr' [PR102270]
Also rename the test so it actually runs.
Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
libstdc++-v3/ChangeLog:
PR libstdc++/102270
* include/std/tuple (_Tuple_impl): Add constexpr to constructor
missed in previous patch.
* testsuite/20_util/tuple/cons/102270.C: Moved to...
* testsuite/20_util/tuple/cons/102270.cc: ...here.
* testsuite/util/testsuite_allocator.h (SimpleAllocator): Add
constexpr to constructor so it can be used for C++20 tests.
diff --git a/libstdc++-v3/include/std/tuple b/libstdc++-v3/include/std/tuple
index 6f0dc6346e1..120c80a2b78 100644
--- a/libstdc++-v3/include/std/tuple
+++ b/libstdc++-v3/include/std/tuple
@@ -330,6 +330,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
{ }
template<typename _Alloc>
+ _GLIBCXX20_CONSTEXPR
_Tuple_impl(allocator_arg_t __tag, const _Alloc& __a,
const _Head& __head, const _Tail&... __tail)
: _Inherited(__tag, __a, __tail...),
diff --git a/libstdc++-v3/testsuite/20_util/tuple/cons/102270.C b/libstdc++-v3/testsuite/20_util/tuple/cons/102270.cc
similarity index 95%
rename from libstdc++-v3/testsuite/20_util/tuple/cons/102270.C
rename to libstdc++-v3/testsuite/20_util/tuple/cons/102270.cc
index 998329817c7..5500cacab6d 100644
--- a/libstdc++-v3/testsuite/20_util/tuple/cons/102270.C
+++ b/libstdc++-v3/testsuite/20_util/tuple/cons/102270.cc
@@ -56,6 +56,9 @@ constexpr bool construct_using_allocator()
std::tuple<X1a, X1a, X1b, X1b> t1a1b(std::allocator_arg, a, 1, i, 1, i);
+ const int c = 0;
+ std::tuple<int, int> tii(std::allocator_arg, a, c, c);
+
return true;
}
static_assert( construct_using_allocator() );
diff --git a/libstdc++-v3/testsuite/util/testsuite_allocator.h b/libstdc++-v3/testsuite/util/testsuite_allocator.h
index 1f7912ea6eb..b5b402858a6 100644
--- a/libstdc++-v3/testsuite/util/testsuite_allocator.h
+++ b/libstdc++-v3/testsuite/util/testsuite_allocator.h
@@ -514,7 +514,7 @@ namespace __gnu_test
{
typedef Tp value_type;
- SimpleAllocator() noexcept { }
+ constexpr SimpleAllocator() noexcept { }
template <class T>
SimpleAllocator(const SimpleAllocator<T>&) { }
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2021-09-17 19:49 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-16 22:07 [committed] libstdc++: Add missing 'constexpr' to std::tuple [PR102270] Jonathan Wakely
2021-09-17 11:25 ` Jonathan Wakely
2021-09-17 19:47 ` [committed] libstdc++: Fix last std::tuple constructor missing 'constexpr' [PR102270] Jonathan Wakely
2021-09-17 19:48 ` Jonathan Wakely
2021-09-17 19:45 Jonathan Wakely
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).