[libcxx-commits] [PATCH] D138731: [libc++] Refactor std::function tests

Louis Dionne via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Wed Dec 14 07:56:33 PST 2022


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG902e28def669: [libc++] Refactor .compile.fail.cpp tests for std::function (authored by ldionne).

Changed prior to commit:
  https://reviews.llvm.org/D138731?vs=478007&id=482864#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D138731/new/

https://reviews.llvm.org/D138731

Files:
  libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/derive_from.compile.fail.cpp
  libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/derive_from.verify.cpp
  libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/deduct_F.fail.cpp
  libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/deduct_F.verify.cpp
  libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke.compile.fail.cpp
  libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke.verify.cpp


Index: libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke.verify.cpp
===================================================================
--- libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke.verify.cpp
+++ libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke.verify.cpp
@@ -6,6 +6,8 @@
 //
 //===----------------------------------------------------------------------===//
 
+// UNSUPPORTED: c++03
+
 // <functional>
 
 // class function<R(ArgTypes...)>
@@ -15,33 +17,11 @@
 #include <functional>
 #include <cassert>
 
-// member data pointer:  cv qualifiers should transfer from argument to return type
-
-struct A_int_1
-{
-    A_int_1() : data_(5) {}
-
-    int data_;
-};
-
-void
-test_int_1()
-{
-    // member data pointer
-    {
-        int A_int_1::*fp = &A_int_1::data_;
-        A_int_1 a;
-        std::function<int& (const A_int_1*)> r2(fp);
-        const A_int_1* ap = &a;
-        assert(r2(ap) == 6);
-        r2(ap) = 7;
-        assert(r2(ap) == 7);
-    }
-}
+// member data pointer: cv qualifiers should transfer from argument to return type
 
-int main(int, char**)
-{
-    test_int_1();
+struct Foo { int data; };
 
-  return 0;
+void f() {
+    int Foo::*fp = &Foo::data;
+    std::function<int& (const Foo*)> r2(fp); // expected-error {{no matching constructor for initialization of}}
 }
Index: libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/derive_from.verify.cpp
===================================================================
--- libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/derive_from.verify.cpp
+++ libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/derive_from.verify.cpp
@@ -6,21 +6,19 @@
 //
 //===----------------------------------------------------------------------===//
 
-// UNSUPPORTED: c++03
-// XFAIL: c++11, c++14
+// UNSUPPORTED: c++03, c++11, c++14
 
 // <functional>
+//
+// Make sure we can't initialize a std::function using an allocator (http://wg21.link/p0302r1).
+// These constructors were removed in C++17.
 
 #include <functional>
-#include <type_traits>
-
-#include "test_macros.h"
+#include <memory>
 
 struct S : public std::function<void()> { using function::function; };
 
-int main(int, char**) {
-   S f1( [](){} );
-   S f2(std::allocator_arg, std::allocator<int>{}, f1);
-
-  return 0;
+void f() {
+  S f1( [](){} );
+  S f2(std::allocator_arg, std::allocator<int>{}, f1); // expected-error {{no matching constructor for initialization of 'S'}}
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D138731.482864.patch
Type: text/x-patch
Size: 2603 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20221214/60a77b2f/attachment-0001.bin>


More information about the libcxx-commits mailing list