diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2017-05-30 17:37:59 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2017-05-30 17:37:59 +0000 |
commit | 10a0bef720b6882fce588a10b07b0584d62eac76 (patch) | |
tree | fb169e84a36c81d64e9d07fac8e8331ec8fc4989 /test | |
parent | b276b1db48faa7328575ab722fe3bc340623f025 (diff) | |
download | src-10a0bef720b6882fce588a10b07b0584d62eac76.tar.gz src-10a0bef720b6882fce588a10b07b0584d62eac76.zip |
Vendor import of libc++ trunk r304222:vendor/libc++/libc++-trunk-r304222
Notes
Notes:
svn path=/vendor/libc++/dist/; revision=319236
svn path=/vendor/libc++/libc++-trunk-r304222/; revision=319237; tag=vendor/libc++/libc++-trunk-r304222
Diffstat (limited to 'test')
2 files changed, 55 insertions, 0 deletions
diff --git a/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.export/from_address.fail.cpp b/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.export/from_address.fail.cpp new file mode 100644 index 000000000000..1c87b9443ecf --- /dev/null +++ b/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.export/from_address.fail.cpp @@ -0,0 +1,46 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// 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, c++11 +// <experimental/coroutine> + +// template <class Promise = void> +// struct coroutine_handle; + +// static coroutine_handle from_address(void*) noexcept + +// Test that `from_address` is explicitly ill-formed when called with a typed +// pointer. The user cannot possibly have a typed pointer to the coroutine. +// FIXME: This behavior is an extension, and should upstreamed into the TS or +// the test removed if the TS changes are rejected. + +#include <experimental/coroutine> +#include <type_traits> +#include <cassert> + +namespace coro = std::experimental; + +int main() +{ + { + using H = coro::coroutine_handle<>; + // expected-error@experimental/coroutine:* 3 {{coroutine_handle<void>::from_address cannot be called with non-void pointers}} + H::from_address((int*)nullptr); // expected-note {{requested here}} + H::from_address((const void*)nullptr); // expected-note {{requested here}} + H::from_address((const char*)nullptr); // expected-note {{requested here}} + } + { + using H = coro::coroutine_handle<int>; + // expected-error@experimental/coroutine:* 1 {{static_assert failed "coroutine_handle<promise_type>::from_address cannot be used with pointers to the coroutine's promise type; use 'from_promise' instead"}} + H::from_address((const char*)nullptr); // expected-note {{requested here}} + // expected-error@experimental/coroutine:* 1 {{coroutine_handle<promise_type>::from_address cannot be called with non-void pointers}} + H::from_address((int*)nullptr); // expected-note {{requested here}} + } +} diff --git a/test/std/experimental/language.support/support.coroutines/lit.local.cfg b/test/std/experimental/language.support/support.coroutines/lit.local.cfg new file mode 100644 index 000000000000..a0b3de8afaa3 --- /dev/null +++ b/test/std/experimental/language.support/support.coroutines/lit.local.cfg @@ -0,0 +1,9 @@ +# If the compiler doesn't support coroutines mark all of the tests under +# this directory as unsupported. Otherwise add the required `-fcoroutines-ts` +# flag. +if 'fcoroutines-ts' not in config.available_features: + config.unsupported = True +else: + import copy + config.test_format.cxx = copy.deepcopy(config.test_format.cxx) + config.test_format.cxx.compile_flags += ['-fcoroutines-ts'] |