summaryrefslogtreecommitdiff
path: root/libstdc++-v3/libsupc++
diff options
context:
space:
mode:
authorredi <redi@138bc75d-0d04-0410-961f-82ee72b054a4>2016-10-28 14:09:33 +0000
committerredi <redi@138bc75d-0d04-0410-961f-82ee72b054a4>2016-10-28 14:09:33 +0000
commitf82bce061abec9783f1a3cc9e3c39fcf7e327cc5 (patch)
treeecd360db0a445c1fa95554f352767c2d6d3cbf9a /libstdc++-v3/libsupc++
parent7361bb02a3432e50435d5deb288f6b759a88c6cf (diff)
downloadgcc-f82bce061abec9783f1a3cc9e3c39fcf7e327cc5.tar.gz
Implement std::launder for C++17
* doc/xml/manual/status_cxx2017.xml: Update status. * doc/html/*: Regenerate. * include/std/type_traits (has_unique_object_representations): Guard with __has_builtin check. * libsupc++/new (launder): Define for C++17. * testsuite/18_support/launder/1.cc: New test. * testsuite/18_support/launder/requirements.cc: New test. * testsuite/18_support/launder/requirements_neg.cc: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@241648 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3/libsupc++')
-rw-r--r--libstdc++-v3/libsupc++/new35
1 files changed, 35 insertions, 0 deletions
diff --git a/libstdc++-v3/libsupc++/new b/libstdc++-v3/libsupc++/new
index 477fadc218c..6bc6c008c18 100644
--- a/libstdc++-v3/libsupc++/new
+++ b/libstdc++-v3/libsupc++/new
@@ -176,6 +176,41 @@ inline void operator delete[](void*, void*) _GLIBCXX_USE_NOEXCEPT { }
//@}
} // extern "C++"
+#if __cplusplus > 201402L
+#ifdef __has_builtin
+# if !__has_builtin(__builtin_launder)
+// Try not to break non-GNU compilers that don't support the built-in:
+# define _GLIBCXX_NO_BUILTIN_LAUNDER 1
+# endif
+#endif
+
+#ifndef _GLIBCXX_NO_BUILTIN_LAUNDER
+namespace std
+{
+#define __cpp_lib_launder 201606
+ /// Pointer optimization barrier [ptr.launder]
+ template<typename _Tp>
+ constexpr _Tp*
+ launder(_Tp* __p) noexcept
+ { return __builtin_launder(__p); }
+
+ // The program is ill-formed if T is a function type or
+ // (possibly cv-qualified) void.
+
+ template<typename _Ret, typename... _Args>
+ void launder(_Ret (*)(_Args...)) = delete;
+ template<typename _Ret, typename... _Args>
+ void launder(_Ret (*)(_Args......)) = delete;
+
+ void launder(void*) = delete;
+ void launder(const void*) = delete;
+ void launder(volatile void*) = delete;
+ void launder(const volatile void*) = delete;
+}
+#endif // _GLIBCXX_NO_BUILTIN_LAUNDER
+#undef _GLIBCXX_NO_BUILTIN_LAUNDER
+#endif // C++17
+
#pragma GCC visibility pop
#endif