[libcxx] r304131 - Fix coroutine test failures caused by API misusages.

Eric Fiselier via cfe-commits cfe-commits at lists.llvm.org
Sun May 28 23:42:02 PDT 2017


Author: ericwf
Date: Mon May 29 01:42:01 2017
New Revision: 304131

URL: http://llvm.org/viewvc/llvm-project?rev=304131&view=rev
Log:
Fix coroutine test failures caused by API misusages.

More tests to come. I think that from_address overload should be deleted
or ill-formed, except for the 'void*' one; The user cannot possibly
have a typed pointer to the coroutine state.

Modified:
    libcxx/trunk/include/experimental/coroutine
    libcxx/trunk/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.capacity/operator_bool.sh.cpp
    libcxx/trunk/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.export/address.sh.cpp
    libcxx/trunk/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.export/from_address.sh.cpp

Modified: libcxx/trunk/include/experimental/coroutine
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/experimental/coroutine?rev=304131&r1=304130&r2=304131&view=diff
==============================================================================
--- libcxx/trunk/include/experimental/coroutine (original)
+++ libcxx/trunk/include/experimental/coroutine Mon May 29 01:42:01 2017
@@ -212,6 +212,15 @@ public:
         return __tmp;
     }
 
+    // NOTE: this overload isn't required by the standard but is needed so
+    // the deleted _Promise* overload doesn't make from_address(nullptr)
+    // ambiguous.
+    // FIXME: should from_address work with nullptr?
+    _LIBCPP_ALWAYS_INLINE
+    static coroutine_handle from_address(nullptr_t) _NOEXCEPT {
+      return {};
+    }
+
     // from_address cannot be used with the coroutines promise type.
     static coroutine_handle from_address(_Promise*) = delete;
 

Modified: libcxx/trunk/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.capacity/operator_bool.sh.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.capacity/operator_bool.sh.cpp?rev=304131&r1=304130&r2=304131&view=diff
==============================================================================
--- libcxx/trunk/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.capacity/operator_bool.sh.cpp (original)
+++ libcxx/trunk/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.capacity/operator_bool.sh.cpp Mon May 29 01:42:01 2017
@@ -48,8 +48,8 @@ void do_test() {
     assert(bool(c) == false);
   }
   { // non-null case
-    int dummy = 42;
-    C c = C::from_address(&dummy);
+    char dummy = 42;
+    C c = C::from_address((void*)&dummy);
     assert(c.address() == &dummy);
     assert(bool(c) == true);
   }

Modified: libcxx/trunk/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.export/address.sh.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.export/address.sh.cpp?rev=304131&r1=304130&r2=304131&view=diff
==============================================================================
--- libcxx/trunk/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.export/address.sh.cpp (original)
+++ libcxx/trunk/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.export/address.sh.cpp Mon May 29 01:42:01 2017
@@ -42,8 +42,8 @@ void do_test() {
     assert(c.address() == nullptr);
   }
   {
-    int dummy = 42;
-    C c = C::from_address(&dummy);
+    char dummy = 42;
+    C c = C::from_address((void*)&dummy);
     assert(c.address() == &dummy);
   }
 }

Modified: libcxx/trunk/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.export/from_address.sh.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.export/from_address.sh.cpp?rev=304131&r1=304130&r2=304131&view=diff
==============================================================================
--- libcxx/trunk/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.export/from_address.sh.cpp (original)
+++ libcxx/trunk/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.export/from_address.sh.cpp Mon May 29 01:42:01 2017
@@ -37,8 +37,8 @@ void do_test() {
     assert(c.address() == nullptr);
   }
   {
-    int dummy = 42;
-    C c = C::from_address(&dummy);
+    char dummy = 42;
+    C c = C::from_address((void*)&dummy);
     assert(c.address() == &dummy);
   }
 }




More information about the cfe-commits mailing list