* 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.
From-SVN: r241648
+2016-10-28 Jonathan Wakely <jwakely@redhat.com>
+
+ * 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.
+
2016-10-27 Uros Bizjak <ubizjak@gmail.com>
PR libstdc++/70975
<a class="link" href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0154r1.html" target="_top">
P0154R1
</a>
- </td><td align="center"> No </td><td align="left"> <code class="code">__cpp_lib_hardware_interference_size >= 201603</code> </td></tr><tr bgcolor="#C8B0B0"><td align="left"> Core Issue 1776: Replacement of class objects containing reference members</td><td align="left">
+ </td><td align="center"> No </td><td align="left"> <code class="code">__cpp_lib_hardware_interference_size >= 201603</code> </td></tr><tr><td align="left"> Core Issue 1776: Replacement of class objects containing reference members</td><td align="left">
<a class="link" href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0137r1.html" target="_top">
P0137R1
</a>
- </td><td align="center"> No </td><td align="left"> <code class="code">__cpp_lib_launder >= 201606</code> </td></tr><tr><td align="left">Wording for <code class="code">std::uncaught_exceptions</code></td><td align="left">
+ </td><td align="center"> 7 </td><td align="left"> <code class="code">__cpp_lib_launder >= 201606</code> </td></tr><tr><td align="left">Wording for <code class="code">std::uncaught_exceptions</code></td><td align="left">
<a class="link" href="http://www.open-std.org/JTC1/sc22/WG21/docs/papers/2014/n4259.pdf" target="_top">
N4259
</a>
<a class="link" href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4089.pdf" target="_top">
N4089
</a>
- </td><td align="center"> 5 ? </td><td align="left"> </td></tr><tr><td align="left"> LWG 2228: Missing SFINAE rule in unique_ptr templated assignment </td><td align="left">
+ </td><td align="center"> 6 </td><td align="left"> </td></tr><tr><td align="left"> LWG 2228: Missing SFINAE rule in unique_ptr templated assignment </td><td align="left">
<a class="link" href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/n4366.html" target="_top">
N4366
</a>
- </td><td align="center"> 5 ? </td><td align="left"> </td></tr><tr><td align="left"> Re-enabling <code class="code">shared_from_this</code></td><td align="left">
+ </td><td align="center"> 6 </td><td align="left"> </td></tr><tr><td align="left"> Re-enabling <code class="code">shared_from_this</code></td><td align="left">
<a class="link" href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0033r1.html" target="_top">
P0033R1
</a>
</row>
<row>
- <?dbhtml bgcolor="#C8B0B0" ?>
<entry> Core Issue 1776: Replacement of class objects containing reference members</entry>
<entry>
<link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0137r1.html">
P0137R1
</link>
</entry>
- <entry align="center"> No </entry>
+ <entry align="center"> 7 </entry>
<entry> <code>__cpp_lib_launder >= 201606</code> </entry>
</row>
N4089
</link>
</entry>
- <entry align="center"> 5 ? </entry>
+ <entry align="center"> 6 </entry>
<entry/>
</row>
N4366
</link>
</entry>
- <entry align="center"> 5 ? </entry>
+ <entry align="center"> 6 </entry>
<entry/>
</row>
template <typename _From, typename _To>
constexpr bool is_convertible_v = is_convertible<_From, _To>::value;
+#ifdef __has_builtin
+# if !__has_builtin(__has_unique_object_representations)
+// Try not to break non-GNU compilers that don't support the built-in:
+# define _GLIBCXX_NO_BUILTIN_HAS_UNIQ_OBJ_REP 1
+# endif
+#endif
+
+#ifndef _GLIBCXX_NO_BUILTIN_HAS_UNIQ_OBJ_REP
# define __cpp_lib_has_unique_object_representations 201606
/// has_unique_object_representations
template<typename _Tp>
remove_cv_t<remove_all_extents_t<_Tp>>
)>
{ };
+#endif
+#undef _GLIBCXX_NO_BUILTIN_HAS_UNIQ_OBJ_REP
#endif // C++17
//@}
} // 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
--- /dev/null
+// Copyright (C) 2016 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++17" }
+// { dg-do run { target c++1z } }
+
+#include <new>
+#include <testsuite_hooks.h>
+#include <testsuite_tr1.h>
+
+void
+test01()
+{
+ struct S {
+ int i;
+ } s;
+ auto p = std::launder( &s.i );
+ VERIFY( p == &s.i );
+}
+
+
+void
+test02()
+{
+ // C++1z 1.8 [intro.object]
+ struct X { const int n; };
+ union U { X x; float f; };
+
+ U u = {{ 1 }};
+ u.f = 5.f; // OK, creates new subobject of u (9.3)
+ X *p = new (&u.x) X {2}; // OK, creates new subobject of u
+ VERIFY(p->n == 2); // OK
+ VERIFY(*std::launder(&u.x.n) == 2); // OK
+ // assert(u.x.n == 2); undefined behavior, u.x does not name new subobject
+}
+
+int
+main()
+{
+ test01();
+ test02();
+}
--- /dev/null
+// Copyright (C) 2016 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++17" }
+// { dg-do compile { target c++1z } }
+
+// NB: This file is for testing new with NO OTHER INCLUDES.
+#include <new>
+
+namespace std {
+ template <class T>
+ constexpr T* launder(T* p) noexcept;
+}
--- /dev/null
+// Copyright (C) 2016 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++17" }
+// { dg-do compile { target c++1z } }
+
+#include <new>
+
+void f1(int) noexcept;
+int f2(const char*, ...);
+
+void
+test01()
+{
+ std::launder( &f1 ); // { dg-error "deleted function" }
+ std::launder( &f2 ); // { dg-error "deleted function" }
+ void* p = nullptr;
+ std::launder( p ); // { dg-error "deleted function" }
+ const void* cp = nullptr;
+ std::launder( cp ); // { dg-error "deleted function" }
+ volatile void* vp = nullptr;
+ std::launder( vp ); // { dg-error "deleted function" }
+ const volatile void* cvp = nullptr;
+ std::launder( cvp ); // { dg-error "deleted function" }
+}