[libcxx-commits] [libcxx] r372777 - [libc++] Implement LWG 2510

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Tue Sep 24 13:18:54 PDT 2019


Author: ldionne
Date: Tue Sep 24 13:18:54 2019
New Revision: 372777

URL: http://llvm.org/viewvc/llvm-project?rev=372777&view=rev
Log:
[libc++] Implement LWG 2510

Summary:
LWG2510 makes tag types like allocator_arg_t explicitly default
constructible instead of implicitly default constructible. It also
makes the constructors for std::pair and std::tuple conditionally
explicit based on the explicit-ness of the default constructibility
for the pair/tuple's elements.

Reviewers: mclow.lists, EricWF

Subscribers: christof, jkorous, dexonsmith, libcxx-commits

Tags: #libc

Differential Revision: https://reviews.llvm.org/D65161

Added:
    libcxx/trunk/test/libcxx/type_traits/is_implicitly_default_constructible.pass.cpp
    libcxx/trunk/test/std/language.support/support.dynamic/nothrow_t.fail.cpp
    libcxx/trunk/test/std/language.support/support.dynamic/nothrow_t.pass.cpp
    libcxx/trunk/test/std/thread/thread.mutex/thread.lock/types.fail.cpp
    libcxx/trunk/test/std/utilities/memory/allocator.tag/allocator_arg.fail.cpp
    libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/default.fail.cpp
    libcxx/trunk/test/std/utilities/utility/pairs/pair.piecewise/piecewise_construct_t.fail.cpp
    libcxx/trunk/test/std/utilities/utility/pairs/pair.piecewise/piecewise_construct_t.pass.cpp
    libcxx/trunk/test/std/utilities/utility/pairs/pairs.pair/default.explicit.fail.cpp
Modified:
    libcxx/trunk/include/__functional_base
    libcxx/trunk/include/__mutex_base
    libcxx/trunk/include/mutex
    libcxx/trunk/include/new
    libcxx/trunk/include/tuple
    libcxx/trunk/include/type_traits
    libcxx/trunk/include/utility
    libcxx/trunk/src/mutex.cpp
    libcxx/trunk/src/utility.cpp
    libcxx/trunk/test/std/thread/thread.mutex/thread.lock/types.pass.cpp
    libcxx/trunk/test/std/utilities/memory/allocator.tag/allocator_arg.pass.cpp
    libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/default.pass.cpp
    libcxx/trunk/test/std/utilities/utility/pairs/pair.piecewise/piecewise_construct.pass.cpp
    libcxx/trunk/test/std/utilities/utility/pairs/pairs.pair/default.pass.cpp
    libcxx/trunk/www/cxx1z_status.html

Modified: libcxx/trunk/include/__functional_base
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__functional_base?rev=372777&r1=372776&r2=372777&view=diff
==============================================================================
--- libcxx/trunk/include/__functional_base (original)
+++ libcxx/trunk/include/__functional_base Tue Sep 24 13:18:54 2019
@@ -558,7 +558,7 @@ struct __is_transparent<_Tp, _Up,
 
 // allocator_arg_t
 
-struct _LIBCPP_TEMPLATE_VIS allocator_arg_t { };
+struct _LIBCPP_TEMPLATE_VIS allocator_arg_t { explicit allocator_arg_t() = default; };
 
 #if defined(_LIBCPP_CXX03_LANG) || defined(_LIBCPP_BUILDING_LIBRARY)
 extern _LIBCPP_EXPORTED_FROM_ABI const allocator_arg_t allocator_arg;

Modified: libcxx/trunk/include/__mutex_base
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__mutex_base?rev=372777&r1=372776&r2=372777&view=diff
==============================================================================
--- libcxx/trunk/include/__mutex_base (original)
+++ libcxx/trunk/include/__mutex_base Tue Sep 24 13:18:54 2019
@@ -66,9 +66,9 @@ public:
 static_assert(is_nothrow_default_constructible<mutex>::value,
               "the default constructor for std::mutex must be nothrow");
 
-struct _LIBCPP_TYPE_VIS defer_lock_t {};
-struct _LIBCPP_TYPE_VIS try_to_lock_t {};
-struct _LIBCPP_TYPE_VIS adopt_lock_t {};
+struct _LIBCPP_TYPE_VIS defer_lock_t { explicit defer_lock_t() = default; };
+struct _LIBCPP_TYPE_VIS try_to_lock_t { explicit try_to_lock_t() = default; };
+struct _LIBCPP_TYPE_VIS adopt_lock_t { explicit adopt_lock_t() = default; };
 
 #if defined(_LIBCPP_CXX03_LANG) || defined(_LIBCPP_BUILDING_LIBRARY)
 

Modified: libcxx/trunk/include/mutex
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/mutex?rev=372777&r1=372776&r2=372777&view=diff
==============================================================================
--- libcxx/trunk/include/mutex (original)
+++ libcxx/trunk/include/mutex Tue Sep 24 13:18:54 2019
@@ -86,9 +86,9 @@ public:
     void unlock();
 };
 
-struct defer_lock_t {};
-struct try_to_lock_t {};
-struct adopt_lock_t {};
+struct defer_lock_t { explicit defer_lock_t() = default; };
+struct try_to_lock_t { explicit try_to_lock_t() = default; };
+struct adopt_lock_t { explicit adopt_lock_t() = default; };
 
 inline constexpr defer_lock_t  defer_lock{};
 inline constexpr try_to_lock_t try_to_lock{};

Modified: libcxx/trunk/include/new
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/new?rev=372777&r1=372776&r2=372777&view=diff
==============================================================================
--- libcxx/trunk/include/new (original)
+++ libcxx/trunk/include/new Tue Sep 24 13:18:54 2019
@@ -39,7 +39,7 @@ struct destroying_delete_t { // C++20
 };
 inline constexpr destroying_delete_t destroying_delete{}; // C++20
 
-struct nothrow_t {};
+struct nothrow_t { explicit nothrow_t() = default; };
 extern const nothrow_t nothrow;
 typedef void (*new_handler)();
 new_handler set_new_handler(new_handler new_p) noexcept;
@@ -126,7 +126,7 @@ namespace std  // purposefully not using
 {
 
 #if !defined(_LIBCPP_ABI_VCRUNTIME)
-struct _LIBCPP_TYPE_VIS nothrow_t {};
+struct _LIBCPP_TYPE_VIS nothrow_t { explicit nothrow_t() = default; };
 extern _LIBCPP_FUNC_VIS const nothrow_t nothrow;
 
 class _LIBCPP_EXCEPTION_ABI bad_alloc

Modified: libcxx/trunk/include/tuple
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/tuple?rev=372777&r1=372776&r2=372777&view=diff
==============================================================================
--- libcxx/trunk/include/tuple (original)
+++ libcxx/trunk/include/tuple Tue Sep 24 13:18:54 2019
@@ -19,7 +19,7 @@ namespace std
 template <class... T>
 class tuple {
 public:
-    constexpr tuple();
+    explicit(see-below) constexpr tuple();
     explicit(see-below) tuple(const T&...);  // constexpr in C++14
     template <class... U>
         explicit(see-below) tuple(U&&...);  // constexpr in C++14
@@ -500,8 +500,19 @@ class _LIBCPP_TEMPLATE_VIS tuple
     struct _CheckArgsConstructor<true, _Dummy>
     {
         template <class ..._Args>
-        static constexpr bool __enable_default() {
-            return __all<is_default_constructible<_Args>::value...>::value;
+        static constexpr bool __enable_implicit_default() {
+            // In C++03, there's no way to implement the resolution of LWG2510.
+#ifdef _LIBCPP_CXX03_LANG
+            return true;
+#else
+            return __all<__is_implicitly_default_constructible<_Args>::value...>::value;
+#endif
+        }
+
+        template <class ..._Args>
+        static constexpr bool __enable_explicit_default() {
+            return __all<is_default_constructible<_Args>::value...>::value
+                && !__enable_implicit_default<_Args...>();
         }
 
         template <class ..._Args>
@@ -641,11 +652,18 @@ class _LIBCPP_TEMPLATE_VIS tuple
         const typename tuple_element<_Jp, tuple<_Up...> >::type&& get(const tuple<_Up...>&&) _NOEXCEPT;
 public:
 
-    template <bool _Dummy = true, class = typename enable_if<
-        _CheckArgsConstructor<_Dummy>::template __enable_default<_Tp...>()
-    >::type>
-    _LIBCPP_INLINE_VISIBILITY
-    _LIBCPP_CONSTEXPR tuple()
+    template <bool _Dummy = true, _EnableIf<
+        _CheckArgsConstructor<_Dummy>::template __enable_implicit_default<_Tp...>()
+    , void*> = nullptr>
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+    tuple()
+        _NOEXCEPT_(__all<is_nothrow_default_constructible<_Tp>::value...>::value) {}
+
+    template <bool _Dummy = true, _EnableIf<
+        _CheckArgsConstructor<_Dummy>::template __enable_explicit_default<_Tp...>()
+    , void*> = nullptr>
+    explicit _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+    tuple()
         _NOEXCEPT_(__all<is_nothrow_default_constructible<_Tp>::value...>::value) {}
 
     tuple(tuple const&) = default;

Modified: libcxx/trunk/include/type_traits
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/type_traits?rev=372777&r1=372776&r2=372777&view=diff
==============================================================================
--- libcxx/trunk/include/type_traits (original)
+++ libcxx/trunk/include/type_traits Tue Sep 24 13:18:54 2019
@@ -2807,6 +2807,21 @@ _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR boo
     = is_default_constructible<_Tp>::value;
 #endif
 
+#ifndef _LIBCPP_CXX03_LANG
+template <class _Tp>
+void __test_implicit_default_constructible(_Tp);
+
+template <class _Tp, class = void>
+struct __is_implicitly_default_constructible
+    : false_type
+{ };
+
+template <class _Tp>
+struct __is_implicitly_default_constructible<_Tp, decltype(__test_implicit_default_constructible<_Tp const&>({}))>
+    : is_default_constructible<_Tp>
+{ };
+#endif // !C++03
+
 // is_copy_constructible
 
 template <class _Tp>

Modified: libcxx/trunk/include/utility
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/utility?rev=372777&r1=372776&r2=372777&view=diff
==============================================================================
--- libcxx/trunk/include/utility (original)
+++ libcxx/trunk/include/utility Tue Sep 24 13:18:54 2019
@@ -69,7 +69,7 @@ struct pair
 
     pair(const pair&) = default;
     pair(pair&&) = default;
-    constexpr pair();
+    explicit(see-below) constexpr pair();
     explicit(see-below) pair(const T1& x, const T2& y);                          // constexpr in C++14
     template <class U, class V> explicit(see-below) pair(U&& x, V&& y);          // constexpr in C++14
     template <class U, class V> explicit(see-below) pair(const pair<U, V>& p);   // constexpr in C++14
@@ -99,7 +99,7 @@ template <class T1, class T2>
 void
 swap(pair<T1, T2>& x, pair<T1, T2>& y) noexcept(noexcept(x.swap(y)));
 
-struct piecewise_construct_t { };
+struct piecewise_construct_t { explicit piecewise_construct_t() = default; };
 inline constexpr piecewise_construct_t piecewise_construct = piecewise_construct_t();
 
 template <class T> struct tuple_size;
@@ -276,7 +276,7 @@ template <class _Tp> constexpr add_const
 template <class _Tp>                        void as_const(const _Tp&&) = delete;
 #endif
 
-struct _LIBCPP_TEMPLATE_VIS piecewise_construct_t { };
+struct _LIBCPP_TEMPLATE_VIS piecewise_construct_t { explicit piecewise_construct_t() = default; };
 #if defined(_LIBCPP_CXX03_LANG) || defined(_LIBCPP_BUILDING_LIBRARY)
 extern _LIBCPP_EXPORTED_FROM_ABI const piecewise_construct_t piecewise_construct;// = piecewise_construct_t();
 #else
@@ -335,9 +335,21 @@ struct _LIBCPP_TEMPLATE_VIS pair
 
     struct _CheckArgs {
       template <class _U1, class _U2>
-      static constexpr bool __enable_default() {
+      static constexpr bool __enable_explicit_default() {
           return is_default_constructible<_U1>::value
-              && is_default_constructible<_U2>::value;
+              && is_default_constructible<_U2>::value
+              && !__enable_implicit_default<_U1, _U2>();
+      }
+
+      template <class _U1, class _U2>
+      static constexpr bool __enable_implicit_default() {
+          // In C++03, there's no way to implement the resolution of LWG2510.
+#ifdef _LIBCPP_CXX03_LANG
+          return true;
+#else
+          return __is_implicitly_default_constructible<_U1>::value
+              && __is_implicitly_default_constructible<_U2>::value;
+#endif
       }
 
       template <class _U1, class _U2>
@@ -388,7 +400,15 @@ struct _LIBCPP_TEMPLATE_VIS pair
     >::type;
 
     template<bool _Dummy = true, _EnableB<
-            _CheckArgsDep<_Dummy>::template __enable_default<_T1, _T2>()
+            _CheckArgsDep<_Dummy>::template __enable_explicit_default<_T1, _T2>()
+    > = false>
+    explicit _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+    pair() _NOEXCEPT_(is_nothrow_default_constructible<first_type>::value &&
+                      is_nothrow_default_constructible<second_type>::value)
+        : first(), second() {}
+
+    template<bool _Dummy = true, _EnableB<
+            _CheckArgsDep<_Dummy>::template __enable_implicit_default<_T1, _T2>()
     > = false>
     _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
     pair() _NOEXCEPT_(is_nothrow_default_constructible<first_type>::value &&

Modified: libcxx/trunk/src/mutex.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/mutex.cpp?rev=372777&r1=372776&r2=372777&view=diff
==============================================================================
--- libcxx/trunk/src/mutex.cpp (original)
+++ libcxx/trunk/src/mutex.cpp Tue Sep 24 13:18:54 2019
@@ -21,9 +21,9 @@
 _LIBCPP_BEGIN_NAMESPACE_STD
 #ifndef _LIBCPP_HAS_NO_THREADS
 
-const defer_lock_t  defer_lock = {};
-const try_to_lock_t try_to_lock = {};
-const adopt_lock_t  adopt_lock = {};
+const defer_lock_t  defer_lock{};
+const try_to_lock_t try_to_lock{};
+const adopt_lock_t  adopt_lock{};
 
 // ~mutex is defined elsewhere
 

Modified: libcxx/trunk/src/utility.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/utility.cpp?rev=372777&r1=372776&r2=372777&view=diff
==============================================================================
--- libcxx/trunk/src/utility.cpp (original)
+++ libcxx/trunk/src/utility.cpp Tue Sep 24 13:18:54 2019
@@ -10,6 +10,6 @@
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 
-const piecewise_construct_t piecewise_construct = {};
+const piecewise_construct_t piecewise_construct{};
 
 _LIBCPP_END_NAMESPACE_STD

Added: libcxx/trunk/test/libcxx/type_traits/is_implicitly_default_constructible.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/type_traits/is_implicitly_default_constructible.pass.cpp?rev=372777&view=auto
==============================================================================
--- libcxx/trunk/test/libcxx/type_traits/is_implicitly_default_constructible.pass.cpp (added)
+++ libcxx/trunk/test/libcxx/type_traits/is_implicitly_default_constructible.pass.cpp Tue Sep 24 13:18:54 2019
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++98, c++03
+
+// <type_traits>
+
+// __is_implicitly_default_constructible<Tp>
+
+#include <type_traits>
+
+
+struct ExplicitlyDefaultConstructible1 {
+    explicit ExplicitlyDefaultConstructible1() = default;
+};
+
+struct ExplicitlyDefaultConstructible2 {
+    explicit ExplicitlyDefaultConstructible2() { }
+};
+
+struct ImplicitlyDefaultConstructible1 {
+    ImplicitlyDefaultConstructible1() { }
+};
+
+struct ImplicitlyDefaultConstructible2 {
+    ImplicitlyDefaultConstructible2() = default;
+};
+
+struct NonDefaultConstructible1 {
+    NonDefaultConstructible1() = delete;
+};
+
+struct NonDefaultConstructible2 {
+    explicit NonDefaultConstructible2() = delete;
+};
+
+struct NonDefaultConstructible3 {
+    NonDefaultConstructible3(NonDefaultConstructible3&&) { }
+};
+
+static_assert(!std::__is_implicitly_default_constructible<ExplicitlyDefaultConstructible1>::value, "");
+static_assert(!std::__is_implicitly_default_constructible<ExplicitlyDefaultConstructible2>::value, "");
+static_assert(std::__is_implicitly_default_constructible<ImplicitlyDefaultConstructible1>::value, "");
+static_assert(std::__is_implicitly_default_constructible<ImplicitlyDefaultConstructible2>::value, "");
+static_assert(!std::__is_implicitly_default_constructible<NonDefaultConstructible1>::value, "");
+static_assert(!std::__is_implicitly_default_constructible<NonDefaultConstructible2>::value, "");
+static_assert(!std::__is_implicitly_default_constructible<NonDefaultConstructible3>::value, "");
+
+int main(int, char**) {
+    return 0;
+}

Added: libcxx/trunk/test/std/language.support/support.dynamic/nothrow_t.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/language.support/support.dynamic/nothrow_t.fail.cpp?rev=372777&view=auto
==============================================================================
--- libcxx/trunk/test/std/language.support/support.dynamic/nothrow_t.fail.cpp (added)
+++ libcxx/trunk/test/std/language.support/support.dynamic/nothrow_t.fail.cpp Tue Sep 24 13:18:54 2019
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++98, c++03
+
+// struct nothrow_t {
+//   explicit nothrow_t() = default;
+// };
+// extern const nothrow_t nothrow;
+
+// This test checks for LWG 2510.
+
+#include <new>
+
+
+std::nothrow_t f() { return {}; } // expected-error 1 {{chosen constructor is explicit in copy-initialization}}
+
+int main(int, char**) {
+    return 0;
+}

Added: libcxx/trunk/test/std/language.support/support.dynamic/nothrow_t.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/language.support/support.dynamic/nothrow_t.pass.cpp?rev=372777&view=auto
==============================================================================
--- libcxx/trunk/test/std/language.support/support.dynamic/nothrow_t.pass.cpp (added)
+++ libcxx/trunk/test/std/language.support/support.dynamic/nothrow_t.pass.cpp Tue Sep 24 13:18:54 2019
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// struct nothrow_t {
+//   explicit nothrow_t() = default;
+// };
+// extern const nothrow_t nothrow;
+
+#include <new>
+
+
+int main(int, char**) {
+  std::nothrow_t x = std::nothrow;
+  (void)x;
+
+  return 0;
+}

Added: libcxx/trunk/test/std/thread/thread.mutex/thread.lock/types.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.mutex/thread.lock/types.fail.cpp?rev=372777&view=auto
==============================================================================
--- libcxx/trunk/test/std/thread/thread.mutex/thread.lock/types.fail.cpp (added)
+++ libcxx/trunk/test/std/thread/thread.mutex/thread.lock/types.fail.cpp Tue Sep 24 13:18:54 2019
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++98, c++03
+
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <mutex>
+
+// struct defer_lock_t { explicit defer_lock_t() = default; };
+// struct try_to_lock_t { explicit try_to_lock_t() = default; };
+// struct adopt_lock_t { explicit adopt_lock_t() = default; };
+
+// This test checks for LWG 2510.
+
+#include <mutex>
+
+
+std::defer_lock_t f1() { return {}; } // expected-error 1 {{chosen constructor is explicit in copy-initialization}}
+std::try_to_lock_t f2() { return {}; } // expected-error 1 {{chosen constructor is explicit in copy-initialization}}
+std::adopt_lock_t f3() { return {}; } // expected-error 1 {{chosen constructor is explicit in copy-initialization}}
+
+int main(int, char**) {
+    return 0;
+}

Modified: libcxx/trunk/test/std/thread/thread.mutex/thread.lock/types.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.mutex/thread.lock/types.pass.cpp?rev=372777&r1=372776&r2=372777&view=diff
==============================================================================
--- libcxx/trunk/test/std/thread/thread.mutex/thread.lock/types.pass.cpp (original)
+++ libcxx/trunk/test/std/thread/thread.mutex/thread.lock/types.pass.cpp Tue Sep 24 13:18:54 2019
@@ -10,16 +10,15 @@
 
 // <mutex>
 
-// struct defer_lock_t {};
-// struct try_to_lock_t {};
-// struct adopt_lock_t {};
+// struct defer_lock_t { explicit defer_lock_t() = default; };
+// struct try_to_lock_t { explicit try_to_lock_t() = default; };
+// struct adopt_lock_t { explicit adopt_lock_t() = default; };
 //
 // constexpr defer_lock_t  defer_lock{};
 // constexpr try_to_lock_t try_to_lock{};
 // constexpr adopt_lock_t  adopt_lock{};
 
 #include <mutex>
-#include <type_traits>
 
 #include "test_macros.h"
 
@@ -33,5 +32,5 @@ int main(int, char**)
     T2 t2 = std::try_to_lock; ((void)t2);
     T3 t3 = std::adopt_lock; ((void)t3);
 
-  return 0;
+    return 0;
 }

Added: libcxx/trunk/test/std/utilities/memory/allocator.tag/allocator_arg.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/allocator.tag/allocator_arg.fail.cpp?rev=372777&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/allocator.tag/allocator_arg.fail.cpp (added)
+++ libcxx/trunk/test/std/utilities/memory/allocator.tag/allocator_arg.fail.cpp Tue Sep 24 13:18:54 2019
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++98, c++03
+
+// <memory>
+
+// struct allocator_arg_t { explicit allocator_arg_t() = default; };
+// const allocator_arg_t allocator_arg = allocator_arg_t();
+
+// This test checks for LWG 2510.
+
+#include <memory>
+
+
+std::allocator_arg_t f() { return {}; } // expected-error 1 {{chosen constructor is explicit in copy-initialization}}
+
+int main(int, char**) {
+    return 0;
+}

Modified: libcxx/trunk/test/std/utilities/memory/allocator.tag/allocator_arg.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/allocator.tag/allocator_arg.pass.cpp?rev=372777&r1=372776&r2=372777&view=diff
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/allocator.tag/allocator_arg.pass.cpp (original)
+++ libcxx/trunk/test/std/utilities/memory/allocator.tag/allocator_arg.pass.cpp Tue Sep 24 13:18:54 2019
@@ -8,7 +8,7 @@
 
 // <memory>
 
-// struct allocator_arg_t { };
+// struct allocator_arg_t { explicit allocator_arg_t() = default; };
 // const allocator_arg_t allocator_arg = allocator_arg_t();
 
 #include <memory>
@@ -21,5 +21,5 @@ int main(int, char**)
 {
     test(std::allocator_arg);
 
-  return 0;
+    return 0;
 }

Added: libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/default.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/default.fail.cpp?rev=372777&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/default.fail.cpp (added)
+++ libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/default.fail.cpp Tue Sep 24 13:18:54 2019
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++98, c++03
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// explicit(see-below) constexpr tuple();
+
+#include <tuple>
+
+
+struct Implicit {
+    Implicit() = default;
+};
+
+struct Explicit {
+    explicit Explicit() = default;
+};
+
+std::tuple<> test1() { return {}; }
+
+std::tuple<Implicit> test2() { return {}; }
+std::tuple<Explicit> test3() { return {}; } // expected-error 1 {{chosen constructor is explicit in copy-initialization}}
+
+std::tuple<Implicit, Implicit> test4() { return {}; }
+std::tuple<Explicit, Implicit> test5() { return {}; } // expected-error 1 {{chosen constructor is explicit in copy-initialization}}
+std::tuple<Implicit, Explicit> test6() { return {}; } // expected-error 1 {{chosen constructor is explicit in copy-initialization}}
+std::tuple<Explicit, Explicit> test7() { return {}; } // expected-error 1 {{chosen constructor is explicit in copy-initialization}}
+
+std::tuple<Implicit, Implicit, Implicit> test8() { return {}; }
+std::tuple<Implicit, Implicit, Explicit> test9() { return {}; } // expected-error 1 {{chosen constructor is explicit in copy-initialization}}
+std::tuple<Implicit, Explicit, Implicit> test10() { return {}; } // expected-error 1 {{chosen constructor is explicit in copy-initialization}}
+std::tuple<Implicit, Explicit, Explicit> test11() { return {}; } // expected-error 1 {{chosen constructor is explicit in copy-initialization}}
+std::tuple<Explicit, Implicit, Implicit> test12() { return {}; } // expected-error 1 {{chosen constructor is explicit in copy-initialization}}
+std::tuple<Explicit, Implicit, Explicit> test13() { return {}; } // expected-error 1 {{chosen constructor is explicit in copy-initialization}}
+std::tuple<Explicit, Explicit, Implicit> test14() { return {}; } // expected-error 1 {{chosen constructor is explicit in copy-initialization}}
+std::tuple<Explicit, Explicit, Explicit> test15() { return {}; } // expected-error 1 {{chosen constructor is explicit in copy-initialization}}
+
+int main(int, char**) {
+    return 0;
+}

Modified: libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/default.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/default.pass.cpp?rev=372777&r1=372776&r2=372777&view=diff
==============================================================================
--- libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/default.pass.cpp (original)
+++ libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/default.pass.cpp Tue Sep 24 13:18:54 2019
@@ -10,7 +10,7 @@
 
 // template <class... Types> class tuple;
 
-// constexpr tuple();
+// explicit(see-below) constexpr tuple();
 
 // UNSUPPORTED: c++98, c++03
 

Modified: libcxx/trunk/test/std/utilities/utility/pairs/pair.piecewise/piecewise_construct.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/utility/pairs/pair.piecewise/piecewise_construct.pass.cpp?rev=372777&r1=372776&r2=372777&view=diff
==============================================================================
--- libcxx/trunk/test/std/utilities/utility/pairs/pair.piecewise/piecewise_construct.pass.cpp (original)
+++ libcxx/trunk/test/std/utilities/utility/pairs/pair.piecewise/piecewise_construct.pass.cpp Tue Sep 24 13:18:54 2019
@@ -12,7 +12,7 @@
 
 // template <class T1, class T2> struct pair
 
-// struct piecewise_construct_t { };
+// struct piecewise_construct_t { explicit piecewise_construct_t() = default; };
 // constexpr piecewise_construct_t piecewise_construct = piecewise_construct_t();
 
 #include <utility>

Added: libcxx/trunk/test/std/utilities/utility/pairs/pair.piecewise/piecewise_construct_t.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/utility/pairs/pair.piecewise/piecewise_construct_t.fail.cpp?rev=372777&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/utility/pairs/pair.piecewise/piecewise_construct_t.fail.cpp (added)
+++ libcxx/trunk/test/std/utilities/utility/pairs/pair.piecewise/piecewise_construct_t.fail.cpp Tue Sep 24 13:18:54 2019
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++98, c++03
+
+// <utility>
+
+// struct piecewise_construct_t { explicit piecewise_construct_t() = default; };
+// constexpr piecewise_construct_t piecewise_construct = piecewise_construct_t();
+
+// This test checks for LWG 2510.
+
+#include <utility>
+
+
+std::piecewise_construct_t f() { return {}; } // expected-error 1 {{chosen constructor is explicit in copy-initialization}}
+
+int main(int, char**) {
+    return 0;
+}

Added: libcxx/trunk/test/std/utilities/utility/pairs/pair.piecewise/piecewise_construct_t.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/utility/pairs/pair.piecewise/piecewise_construct_t.pass.cpp?rev=372777&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/utility/pairs/pair.piecewise/piecewise_construct_t.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/utility/pairs/pair.piecewise/piecewise_construct_t.pass.cpp Tue Sep 24 13:18:54 2019
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++98, c++03
+
+// <utility>
+
+// struct piecewise_construct_t { explicit piecewise_construct_t() = default; };
+// constexpr piecewise_construct_t piecewise_construct = piecewise_construct_t();
+
+#include <utility>
+
+
+int main(int, char**) {
+    std::piecewise_construct_t x = std::piecewise_construct;
+    (void)x;
+
+    return 0;
+}

Added: libcxx/trunk/test/std/utilities/utility/pairs/pairs.pair/default.explicit.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/utility/pairs/pairs.pair/default.explicit.fail.cpp?rev=372777&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/utility/pairs/pairs.pair/default.explicit.fail.cpp (added)
+++ libcxx/trunk/test/std/utilities/utility/pairs/pairs.pair/default.explicit.fail.cpp Tue Sep 24 13:18:54 2019
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++98, c++03
+
+// <utility>
+
+// template <class T1, class T2> struct pair
+
+// explicit(see-below) constexpr pair();
+
+// This test checks the conditional explicitness of std::pair's default
+// constructor as introduced by the resolution of LWG 2510.
+
+#include <utility>
+
+
+struct ImplicitlyDefaultConstructible {
+    ImplicitlyDefaultConstructible() = default;
+};
+
+struct ExplicitlyDefaultConstructible {
+    explicit ExplicitlyDefaultConstructible() = default;
+};
+
+std::pair<ImplicitlyDefaultConstructible, ExplicitlyDefaultConstructible> test1() { return {}; } // expected-error 1 {{chosen constructor is explicit in copy-initialization}}
+std::pair<ExplicitlyDefaultConstructible, ImplicitlyDefaultConstructible> test2() { return {}; } // expected-error 1 {{chosen constructor is explicit in copy-initialization}}
+std::pair<ExplicitlyDefaultConstructible, ExplicitlyDefaultConstructible> test3() { return {}; } // expected-error 1 {{chosen constructor is explicit in copy-initialization}}
+std::pair<ImplicitlyDefaultConstructible, ImplicitlyDefaultConstructible> test4() { return {}; }
+
+int main(int, char**) {
+    return 0;
+}

Modified: libcxx/trunk/test/std/utilities/utility/pairs/pairs.pair/default.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/utility/pairs/pairs.pair/default.pass.cpp?rev=372777&r1=372776&r2=372777&view=diff
==============================================================================
--- libcxx/trunk/test/std/utilities/utility/pairs/pairs.pair/default.pass.cpp (original)
+++ libcxx/trunk/test/std/utilities/utility/pairs/pairs.pair/default.pass.cpp Tue Sep 24 13:18:54 2019
@@ -10,7 +10,7 @@
 
 // template <class T1, class T2> struct pair
 
-// constexpr pair();
+// explicit(see-below) constexpr pair();
 
 // This test doesn't pass due to a constexpr bug in GCC 4.9 that fails
 // to initialize any type without a user provided constructor in a constant

Modified: libcxx/trunk/www/cxx1z_status.html
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/www/cxx1z_status.html?rev=372777&r1=372776&r2=372777&view=diff
==============================================================================
--- libcxx/trunk/www/cxx1z_status.html (original)
+++ libcxx/trunk/www/cxx1z_status.html Tue Sep 24 13:18:54 2019
@@ -372,7 +372,7 @@
 	<tr><td><a href="https://wg21.link/LWG2468">2468</a></td><td>Self-move-assignment of library types</td><td>Issaquah</td><td></td></tr>
 	<tr><td><a href="https://wg21.link/LWG2475">2475</a></td><td>Allow overwriting of std::basic_string terminator with charT() to allow cleaner interoperation with legacy APIs</td><td>Issaquah</td><td>Complete</td></tr>
 	<tr><td><a href="https://wg21.link/LWG2503">2503</a></td><td>multiline option should be added to syntax_option_type</td><td>Issaquah</td><td></td></tr>
-	<tr><td><a href="https://wg21.link/LWG2510">2510</a></td><td>Tag types should not be DefaultConstructible</td><td>Issaquah</td><td></td></tr>
+	<tr><td><a href="https://wg21.link/LWG2510">2510</a></td><td>Tag types should not be DefaultConstructible</td><td>Issaquah</td><td>Complete</td></tr>
 	<tr><td><a href="https://wg21.link/LWG2514">2514</a></td><td>Type traits must not be final</td><td>Issaquah</td><td>Complete</td></tr>
 	<tr><td><a href="https://wg21.link/LWG2518">2518</a></td><td>[fund.ts.v2] Non-member swap for propagate_const should call member swap</td><td>Issaquah</td><td>Complete</td></tr>
 	<tr><td><a href="https://wg21.link/LWG2519">2519</a></td><td>Iterator operator-= has gratuitous undefined behaviour</td><td>Issaquah</td><td>Complete</td></tr>




More information about the libcxx-commits mailing list