diff --git a/stl/inc/coroutine b/stl/inc/coroutine index 268f816a014..b7ad50a954f 100644 --- a/stl/inc/coroutine +++ b/stl/inc/coroutine @@ -9,12 +9,10 @@ #if _STL_COMPILER_PREPROCESSOR #ifdef _RESUMABLE_FUNCTIONS_SUPPORTED -_EMIT_STL_WARNING(STL4039, "The contents of are not available with /await. " - "Remove /await or use /await:strict for standard coroutines. " - "Use for legacy /await support."); -#else // ^^^ /await / no /await vvv -#ifndef __cpp_lib_coroutine -_EMIT_STL_WARNING(STL4038, "The contents of are available only with C++20 or later or /await:strict."); +_EMIT_STL_WARNING(STL4039, "The header is incompatible with the deprecated /await compiler option."); +#elif !defined(__cpp_lib_coroutine) +_EMIT_STL_WARNING(STL4038, "The contents of are available only with C++20 or later " + "(or /await:strict in C++14/17)."); #else // ^^^ is not available / is available vvv #ifndef _ALLOW_COROUTINE_ABI_MISMATCH #pragma detect_mismatch("_COROUTINE_ABI", "2") @@ -270,7 +268,6 @@ _STL_RESTORE_CLANG_WARNINGS #pragma warning(pop) #pragma pack(pop) -#endif // ^^^ defined(__cpp_lib_coroutine) ^^^ -#endif // ^^^ !defined(_RESUMABLE_FUNCTIONS_SUPPORTED) ^^^ +#endif // ^^^ is available ^^^ #endif // _STL_COMPILER_PREPROCESSOR #endif // _COROUTINE_ diff --git a/stl/inc/experimental/coroutine b/stl/inc/experimental/coroutine index 4bf7bec477c..b0cc97a12bb 100644 --- a/stl/inc/experimental/coroutine +++ b/stl/inc/experimental/coroutine @@ -25,15 +25,19 @@ _STL_DISABLE_CLANG_WARNINGS #pragma push_macro("new") #undef new -#if defined(__clang__) && !defined(_SILENCE_CLANG_COROUTINE_MESSAGE) -#error The , , and \ -headers do not support Clang, but the C++20 header does. -#endif // defined(__clang__) && !defined(_SILENCE_CLANG_COROUTINE_MESSAGE) - -#ifdef __cpp_impl_coroutine -#error The and headers are only supported with \ -/await and implement pre-C++20 coroutine support. Use for standard C++20 coroutines. -#endif // defined(__cpp_impl_coroutine) +#ifdef __clang__ +_EMIT_STL_ERROR(STL1009, "The , , and " + "headers do not support Clang, but the C++20 and C++23 headers do."); +#elif defined(__cpp_impl_coroutine) +_EMIT_STL_ERROR(STL1010, "You're compiling with support for standard C++20 coroutines " + "(also available with /await:strict in C++14/17), so you should include " + "instead of and ."); +#elif !defined(_SILENCE_EXPERIMENTAL_COROUTINE_DEPRECATION_WARNINGS) +_EMIT_STL_ERROR(STL1011, "The /await compiler option, , , and " + " are deprecated by Microsoft and will be REMOVED SOON. " + "They are superseded by the C++20 and C++23 headers. You can define " + "_SILENCE_EXPERIMENTAL_COROUTINE_DEPRECATION_WARNINGS to suppress this error for now."); +#endif // _SILENCE_EXPERIMENTAL_COROUTINE_DEPRECATION_WARNINGS // intrinsics used in implementation of coroutine_handle extern "C" size_t _coro_resume(void*) noexcept; diff --git a/stl/inc/experimental/generator b/stl/inc/experimental/generator index fb39c703c2a..f4ce453422f 100644 --- a/stl/inc/experimental/generator +++ b/stl/inc/experimental/generator @@ -13,12 +13,23 @@ #endif #include -#if defined(__cpp_impl_coroutine) +#ifdef __clang__ +_EMIT_STL_ERROR(STL1009, "The , , and " + "headers do not support Clang, but the C++20 and C++23 headers do."); +#elif !defined(_SILENCE_EXPERIMENTAL_COROUTINE_DEPRECATION_WARNINGS) +_EMIT_STL_ERROR(STL1011, "The /await compiler option, , , and " + " are deprecated by Microsoft and will be REMOVED SOON. " + "They are superseded by the C++20 and C++23 headers. You can define " + "_SILENCE_EXPERIMENTAL_COROUTINE_DEPRECATION_WARNINGS to suppress this error for now."); +#elif defined(__cpp_impl_coroutine) #include #elif defined(__cpp_coroutines) #include #else // ^^^ legacy coroutines / no coroutine support vvv -#error requires /std:c++latest or /await compiler options +_EMIT_STL_ERROR(STL1012, "You've included the header without compiler support for " + "legacy coroutines (available with the deprecated /await compiler option) or " + "standard C++20 coroutines (also available with /await:strict in C++14/17). " + "You should include C++23 instead of ."); #endif // ^^^ no coroutine support ^^^ #pragma pack(push, _CRT_PACKING) diff --git a/stl/inc/yvals_core.h b/stl/inc/yvals_core.h index 0d7cbd7ed47..3f2c717498d 100644 --- a/stl/inc/yvals_core.h +++ b/stl/inc/yvals_core.h @@ -1521,7 +1521,7 @@ _EMIT_STL_ERROR(STL1004, "C++98 unexpected() is incompatible with C++23 unexpect // next warning number: STL4049 -// next error number: STL1009 +// next error number: STL1013 // P0619R4 Removing C++17-Deprecated Features #ifndef _HAS_FEATURES_REMOVED_IN_CXX20 diff --git a/tests/std/tests/VSO_0971246_legacy_await_headers/test.cpp b/tests/std/tests/VSO_0971246_legacy_await_headers/test.cpp index 8bab6fc16a8..3349b3052a7 100644 --- a/tests/std/tests/VSO_0971246_legacy_await_headers/test.cpp +++ b/tests/std/tests/VSO_0971246_legacy_await_headers/test.cpp @@ -1,6 +1,8 @@ // Copyright (c) Microsoft Corporation. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +#define _SILENCE_EXPERIMENTAL_COROUTINE_DEPRECATION_WARNINGS + #include #include #include