aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Wakely <jwakely@redhat.com>2019-10-25 18:02:35 +0100
committerJonathan Wakely <redi@gcc.gnu.org>2019-10-25 18:02:35 +0100
commiteadcde8e8f53c950fc17b52fd33adda40d28f7af (patch)
tree4d27dc4cf1824e4b37fa393498803ee9a38bf8d8
parent2cd6630fc0218580f29e87ea418d9e435d062412 (diff)
downloadgcc-eadcde8e8f53c950fc17b52fd33adda40d28f7af.zip
gcc-eadcde8e8f53c950fc17b52fd33adda40d28f7af.tar.gz
gcc-eadcde8e8f53c950fc17b52fd33adda40d28f7af.tar.bz2
Fix compilation with Clang
The new constexpr destructor on std::allocator breaks compilation with Clang in C++2a mode. This only makes it constexpr if the compiler supports the P0784R7 features. * include/bits/allocator.h: Check __cpp_constexpr_dynamic_alloc before making the std::allocator destructor constexpr. * testsuite/20_util/allocator/requirements/constexpr.cc: New test. From-SVN: r277458
-rw-r--r--libstdc++-v3/ChangeLog5
-rw-r--r--libstdc++-v3/include/bits/allocator.h4
-rw-r--r--libstdc++-v3/testsuite/20_util/allocator/requirements/constexpr.cc28
3 files changed, 36 insertions, 1 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index d1f0e3a..7997273 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,7 +1,12 @@
2019-10-25 Jonathan Wakely <jwakely@redhat.com>
+ * include/bits/allocator.h: Check __cpp_constexpr_dynamic_alloc
+ before making the std::allocator destructor constexpr.
+ * testsuite/20_util/allocator/requirements/constexpr.cc: New test.
+
* include/bits/range_cmp.h: Check __cpp_lib_concepts before defining
concepts. Fix comment.
+ * include/bits/allocator.h
2019-10-25 Gerald Pfeifer <gerald@pfeifer.com>
diff --git a/libstdc++-v3/include/bits/allocator.h b/libstdc++-v3/include/bits/allocator.h
index 2559c57..00d7461 100644
--- a/libstdc++-v3/include/bits/allocator.h
+++ b/libstdc++-v3/include/bits/allocator.h
@@ -160,7 +160,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
_GLIBCXX20_CONSTEXPR
allocator(const allocator<_Tp1>&) _GLIBCXX_NOTHROW { }
- _GLIBCXX20_CONSTEXPR
+#if __cpp_constexpr_dynamic_alloc
+ constexpr
+#endif
~allocator() _GLIBCXX_NOTHROW { }
#if __cplusplus > 201703L
diff --git a/libstdc++-v3/testsuite/20_util/allocator/requirements/constexpr.cc b/libstdc++-v3/testsuite/20_util/allocator/requirements/constexpr.cc
new file mode 100644
index 0000000..6a6dbf1
--- /dev/null
+++ b/libstdc++-v3/testsuite/20_util/allocator/requirements/constexpr.cc
@@ -0,0 +1,28 @@
+// Copyright (C) 2019 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/>.
+
+// { dg-options "-std=gnu++2a" }
+// { dg-do compile { target c++2a } }
+
+#include <memory>
+
+constexpr bool f()
+{
+ std::allocator<int> a;
+ return std::allocator_traits<std::allocator<int>>::max_size(a) > 0;
+}
+static_assert( f() );