]> gcc.gnu.org Git - gcc.git/commitdiff
libstdc++: Use Clang attribute instead of __constinit
authorJonathan Wakely <jwakely@redhat.com>
Thu, 20 Jan 2022 11:18:34 +0000 (11:18 +0000)
committerJonathan Wakely <jwakely@redhat.com>
Thu, 20 Jan 2022 12:29:29 +0000 (12:29 +0000)
Clang doesn't support the __constinit extension that we use pre-C++20,
but it does have its own equivalent attribute that can be used instead.

This makes it a little easier to use Clang to build libstdc++ (which
isn't supported. but is sometimes attempted for esoteric targets).

libstdc++-v3/ChangeLog:

* src/c++11/cxx11-ios_failure.cc (__constinit): Define as
equivalent attribute for Clang.
* src/c++11/future.cc (__constinit): Likewise.
* src/c++11/system_error.cc (__constinit): Likewise.
* src/c++17/memory_resource.cc (__constinit): Likewise.

libstdc++-v3/src/c++11/cxx11-ios_failure.cc
libstdc++-v3/src/c++11/future.cc
libstdc++-v3/src/c++11/system_error.cc
libstdc++-v3/src/c++17/memory_resource.cc

index ba4b1413bf9ca7ad606067cebab5f471e966d8ed..14a7f9cfcb1cbf9824179266f0f06705a596f776 100644 (file)
 # error This file should not be compiled for this configuration.
 #endif
 
+#if __has_cpp_attribute(clang::require_constant_initialization)
+#  define __constinit [[clang::require_constant_initialization]]
+#endif
+
 namespace
 {
   struct io_error_category final : std::error_category
index 488ff17a1e6f92dc32d0071e936fb8217cb71cfc..c52c057ba1d4acbacd9b54bacd2c9c42f477241e 100644 (file)
 #include <future>
 #include <bits/functexcept.h>
 
+#if __has_cpp_attribute(clang::require_constant_initialization)
+#  define __constinit [[clang::require_constant_initialization]]
+#endif
+
 namespace
 {
   struct future_error_category final : public std::error_category
index 789f2b45382b7bdecda6b7b98c6225305a446e63..7b1a5a20637def5cb95e151c099fca9c0f2f8caf 100644 (file)
 #include <windows.h>
 #endif
 
+#if __has_cpp_attribute(clang::require_constant_initialization)
+#  define __constinit [[clang::require_constant_initialization]]
+#endif
+
 namespace
 {
   using std::string;
index 5cdb35df2cd02b1f490e96c9ff42d90d1c9b78c2..bb6334c96947d6d3a3c5d69890c4f6f9479f01f5 100644 (file)
 # include <bits/move.h>                // std::__exchange
 #endif
 
+#if __has_cpp_attribute(clang::require_constant_initialization)
+#  define __constinit [[clang::require_constant_initialization]]
+#endif
+
 namespace std _GLIBCXX_VISIBILITY(default)
 {
 _GLIBCXX_BEGIN_NAMESPACE_VERSION
This page took 0.068309 seconds and 5 git commands to generate.