Skip to content

Commit 1118f37

Browse files
Deprecate experimental coroutine headers (#5804)
1 parent 7dff4d7 commit 1118f37

File tree

5 files changed

+34
-20
lines changed

5 files changed

+34
-20
lines changed

stl/inc/coroutine

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,10 @@
99
#if _STL_COMPILER_PREPROCESSOR
1010

1111
#ifdef _RESUMABLE_FUNCTIONS_SUPPORTED
12-
_EMIT_STL_WARNING(STL4039, "The contents of <coroutine> are not available with /await. "
13-
"Remove /await or use /await:strict for standard coroutines. "
14-
"Use <experimental/coroutine> for legacy /await support.");
15-
#else // ^^^ /await / no /await vvv
16-
#ifndef __cpp_lib_coroutine
17-
_EMIT_STL_WARNING(STL4038, "The contents of <coroutine> are available only with C++20 or later or /await:strict.");
12+
_EMIT_STL_WARNING(STL4039, "The <coroutine> header is incompatible with the deprecated /await compiler option.");
13+
#elif !defined(__cpp_lib_coroutine)
14+
_EMIT_STL_WARNING(STL4038, "The contents of <coroutine> are available only with C++20 or later "
15+
"(or /await:strict in C++14/17).");
1816
#else // ^^^ <coroutine> is not available / <coroutine> is available vvv
1917
#ifndef _ALLOW_COROUTINE_ABI_MISMATCH
2018
#pragma detect_mismatch("_COROUTINE_ABI", "2")
@@ -270,7 +268,6 @@ _STL_RESTORE_CLANG_WARNINGS
270268
#pragma warning(pop)
271269
#pragma pack(pop)
272270

273-
#endif // ^^^ defined(__cpp_lib_coroutine) ^^^
274-
#endif // ^^^ !defined(_RESUMABLE_FUNCTIONS_SUPPORTED) ^^^
271+
#endif // ^^^ <coroutine> is available ^^^
275272
#endif // _STL_COMPILER_PREPROCESSOR
276273
#endif // _COROUTINE_

stl/inc/experimental/coroutine

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,19 @@ _STL_DISABLE_CLANG_WARNINGS
2525
#pragma push_macro("new")
2626
#undef new
2727

28-
#if defined(__clang__) && !defined(_SILENCE_CLANG_COROUTINE_MESSAGE)
29-
#error The <experimental/coroutine>, <experimental/generator>, and <experimental/resumable> \
30-
headers do not support Clang, but the C++20 <coroutine> header does.
31-
#endif // defined(__clang__) && !defined(_SILENCE_CLANG_COROUTINE_MESSAGE)
32-
33-
#ifdef __cpp_impl_coroutine
34-
#error The <experimental/coroutine> and <experimental/resumable> headers are only supported with \
35-
/await and implement pre-C++20 coroutine support. Use <coroutine> for standard C++20 coroutines.
36-
#endif // defined(__cpp_impl_coroutine)
28+
#ifdef __clang__
29+
_EMIT_STL_ERROR(STL1009, "The <experimental/coroutine>, <experimental/generator>, and <experimental/resumable> "
30+
"headers do not support Clang, but the C++20 <coroutine> and C++23 <generator> headers do.");
31+
#elif defined(__cpp_impl_coroutine)
32+
_EMIT_STL_ERROR(STL1010, "You're compiling with support for standard C++20 coroutines "
33+
"(also available with /await:strict in C++14/17), so you should include <coroutine> "
34+
"instead of <experimental/coroutine> and <experimental/resumable>.");
35+
#elif !defined(_SILENCE_EXPERIMENTAL_COROUTINE_DEPRECATION_WARNINGS)
36+
_EMIT_STL_ERROR(STL1011, "The /await compiler option, <experimental/coroutine>, <experimental/generator>, and "
37+
"<experimental/resumable> are deprecated by Microsoft and will be REMOVED SOON. "
38+
"They are superseded by the C++20 <coroutine> and C++23 <generator> headers. You can define "
39+
"_SILENCE_EXPERIMENTAL_COROUTINE_DEPRECATION_WARNINGS to suppress this error for now.");
40+
#endif // _SILENCE_EXPERIMENTAL_COROUTINE_DEPRECATION_WARNINGS
3741

3842
// intrinsics used in implementation of coroutine_handle
3943
extern "C" size_t _coro_resume(void*) noexcept;

stl/inc/experimental/generator

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,23 @@
1313
#endif
1414
#include <memory>
1515

16-
#if defined(__cpp_impl_coroutine)
16+
#ifdef __clang__
17+
_EMIT_STL_ERROR(STL1009, "The <experimental/coroutine>, <experimental/generator>, and <experimental/resumable> "
18+
"headers do not support Clang, but the C++20 <coroutine> and C++23 <generator> headers do.");
19+
#elif !defined(_SILENCE_EXPERIMENTAL_COROUTINE_DEPRECATION_WARNINGS)
20+
_EMIT_STL_ERROR(STL1011, "The /await compiler option, <experimental/coroutine>, <experimental/generator>, and "
21+
"<experimental/resumable> are deprecated by Microsoft and will be REMOVED SOON. "
22+
"They are superseded by the C++20 <coroutine> and C++23 <generator> headers. You can define "
23+
"_SILENCE_EXPERIMENTAL_COROUTINE_DEPRECATION_WARNINGS to suppress this error for now.");
24+
#elif defined(__cpp_impl_coroutine)
1725
#include <coroutine>
1826
#elif defined(__cpp_coroutines)
1927
#include <experimental/resumable>
2028
#else // ^^^ legacy coroutines / no coroutine support vvv
21-
#error <experimental/generator> requires /std:c++latest or /await compiler options
29+
_EMIT_STL_ERROR(STL1012, "You've included the <experimental/generator> header without compiler support for "
30+
"legacy coroutines (available with the deprecated /await compiler option) or "
31+
"standard C++20 coroutines (also available with /await:strict in C++14/17). "
32+
"You should include C++23 <generator> instead of <experimental/generator>.");
2233
#endif // ^^^ no coroutine support ^^^
2334

2435
#pragma pack(push, _CRT_PACKING)

stl/inc/yvals_core.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1521,7 +1521,7 @@ _EMIT_STL_ERROR(STL1004, "C++98 unexpected() is incompatible with C++23 unexpect
15211521

15221522
// next warning number: STL4049
15231523

1524-
// next error number: STL1009
1524+
// next error number: STL1013
15251525

15261526
// P0619R4 Removing C++17-Deprecated Features
15271527
#ifndef _HAS_FEATURES_REMOVED_IN_CXX20

tests/std/tests/VSO_0971246_legacy_await_headers/test.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// Copyright (c) Microsoft Corporation.
22
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
33

4+
#define _SILENCE_EXPERIMENTAL_COROUTINE_DEPRECATION_WARNINGS
5+
46
#include <cstdio>
57
#include <experimental/generator>
68
#include <future>

0 commit comments

Comments
 (0)