summaryrefslogtreecommitdiffstats
path: root/libcxx/src/experimental/memory_resource.cpp
diff options
context:
space:
mode:
authorEric Fiselier <eric@efcs.ca>2018-07-16 20:01:59 +0000
committerEric Fiselier <eric@efcs.ca>2018-07-16 20:01:59 +0000
commit241d4ad761302695a500fa62d58eeb8aaf72d95f (patch)
tree5be59a6b5c501883b6076d33a02478341f4b0796 /libcxx/src/experimental/memory_resource.cpp
parentc7f8ac7896cf4147adca21220e7c4599bcee5743 (diff)
downloadbcm5719-llvm-241d4ad761302695a500fa62d58eeb8aaf72d95f.tar.gz
bcm5719-llvm-241d4ad761302695a500fa62d58eeb8aaf72d95f.zip
Fix PR38160 - init_priority attribute not supported by GCC on Apple.
This patch guards the use of __attribute__((init_priority(101))) within memory_resource.cpp when building with compilers that don't support it. Specifically GCC on Apple platforms, and MSVC. llvm-svn: 337205
Diffstat (limited to 'libcxx/src/experimental/memory_resource.cpp')
-rw-r--r--libcxx/src/experimental/memory_resource.cpp13
1 files changed, 12 insertions, 1 deletions
diff --git a/libcxx/src/experimental/memory_resource.cpp b/libcxx/src/experimental/memory_resource.cpp
index a6eca3743ea..a3b64cc8b49 100644
--- a/libcxx/src/experimental/memory_resource.cpp
+++ b/libcxx/src/experimental/memory_resource.cpp
@@ -68,12 +68,23 @@ union ResourceInitHelper {
_LIBCPP_CONSTEXPR_AFTER_CXX11 ResourceInitHelper() : resources() {}
~ResourceInitHelper() {}
};
+
+// Detect if the init_priority attribute is supported.
+#if (defined(_LIBCPP_COMPILER_GCC) && defined(__APPLE__)) \
+ || defined(_LIBCPP_COMPILER_MSVC)
+// GCC on Apple doesn't support the init priority attribute,
+// and MSVC doesn't support any GCC attributes.
+# define _LIBCPP_INIT_PRIORITY_MAX
+#else
+# define _LIBCPP_INIT_PRIORITY_MAX __attribute__((init_priority(101)))
+#endif
+
// When compiled in C++14 this initialization should be a constant expression.
// Only in C++11 is "init_priority" needed to ensure initialization order.
#if _LIBCPP_STD_VER > 11
_LIBCPP_SAFE_STATIC
#endif
-ResourceInitHelper res_init __attribute__((init_priority (101)));
+ResourceInitHelper res_init _LIBCPP_INIT_PRIORITY_MAX;
} // end namespace
OpenPOWER on IntegriCloud