From: Jonathan Wakely Date: Fri, 25 Oct 2019 17:02:35 +0000 (+0100) Subject: Fix compilation with Clang X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=eadcde8e8f53c950fc17b52fd33adda40d28f7af;p=gcc.git 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 --- diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index d1f0e3a4cd4..7997273a857 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,7 +1,12 @@ 2019-10-25 Jonathan Wakely + * 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 diff --git a/libstdc++-v3/include/bits/allocator.h b/libstdc++-v3/include/bits/allocator.h index 2559c57b12e..00d7461e42e 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 00000000000..6a6dbf1833f --- /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 +// . + +// { dg-options "-std=gnu++2a" } +// { dg-do compile { target c++2a } } + +#include + +constexpr bool f() +{ + std::allocator a; + return std::allocator_traits>::max_size(a) > 0; +} +static_assert( f() );