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
This commit is contained in:
Jonathan Wakely 2019-10-25 18:02:35 +01:00 committed by Jonathan Wakely
parent 2cd6630fc0
commit eadcde8e8f
3 changed files with 36 additions and 1 deletions

View File

@ -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>

View File

@ -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

View File

@ -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() );