ChuanqiXu created this revision.
ChuanqiXu added reviewers: Quuxplusone, ldionne.
ChuanqiXu added projects: clang, libc++.
Herald added a subscriber: lxfind.
ChuanqiXu requested review of this revision.
Herald added subscribers: libcxx-commits, cfe-commits.
Herald added a reviewer: libc++.
Since we've decided the to not support `std::experimental::coroutine*`, we
should tell the user they need to update.
We could emit warning on the compiler side or in libc++'s side by `#warning`
directives.
I choose to warn on the compiler side since some people might use `libstdc++ `
+ self-defined `coroutine` header (Seastar is an example:
https://github.com/scylladb/seastar/blob/master/include/seastar/core/std-coroutine.hh).
Since new warning might break the libcxx's CI system, I add `-Wno-coroutine`
for the legacy tests. I guess it would be OK since the legacy test would be
removed.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D113977
Files:
clang/include/clang/Basic/DiagnosticGroups.td
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/Sema/SemaCoroutine.cpp
clang/test/SemaCXX/co_await-range-for-exp-namespace.cpp
clang/test/SemaCXX/coreturn-eh-exp-namespace.cpp
clang/test/SemaCXX/coreturn-exp-namespace.cpp
clang/test/SemaCXX/coroutine-final-suspend-noexcept-exp-namespace.cpp
clang/test/SemaCXX/coroutine-rvo-exp-namespace.cpp
clang/test/SemaCXX/coroutine-seh-exp-namespace.cpp
clang/test/SemaCXX/coroutine-traits-undefined-template-exp-namespace.cpp
clang/test/SemaCXX/coroutine-unhandled_exception-warning-exp-namespace.cpp
clang/test/SemaCXX/coroutine_handle-address-return-type-exp-namespace.cpp
clang/test/SemaCXX/coroutines-exp-namespace.cpp
libcxx/test/libcxx/experimental/language.support/support.coroutines/dialect_support.pass.cpp
libcxx/test/std/experimental/language.support/support.coroutines/lit.local.cfg
Index: libcxx/test/std/experimental/language.support/support.coroutines/lit.local.cfg
===================================================================
--- libcxx/test/std/experimental/language.support/support.coroutines/lit.local.cfg
+++ libcxx/test/std/experimental/language.support/support.coroutines/lit.local.cfg
@@ -5,3 +5,4 @@
config.unsupported = True
else:
config.test_format.addCompileFlags(config, '-fcoroutines-ts')
+ config.test_format.addCompileFlags(config, '-Wno-coroutine')
Index: libcxx/test/libcxx/experimental/language.support/support.coroutines/dialect_support.pass.cpp
===================================================================
--- libcxx/test/libcxx/experimental/language.support/support.coroutines/dialect_support.pass.cpp
+++ libcxx/test/libcxx/experimental/language.support/support.coroutines/dialect_support.pass.cpp
@@ -7,7 +7,7 @@
//===----------------------------------------------------------------------===//
// REQUIRES: fcoroutines-ts
-// ADDITIONAL_COMPILE_FLAGS: -fcoroutines-ts
+// ADDITIONAL_COMPILE_FLAGS: -fcoroutines-ts -Wno-coroutine
// A simple "breathing" test that checks that <experimental/coroutine>
// can be parsed and used in all dialects, including C++03 in order to match
Index: clang/test/SemaCXX/coroutines-exp-namespace.cpp
===================================================================
--- clang/test/SemaCXX/coroutines-exp-namespace.cpp
+++ clang/test/SemaCXX/coroutines-exp-namespace.cpp
@@ -83,7 +83,7 @@
struct DummyVoidTag {};
DummyVoidTag no_specialization() { // expected-error {{this function cannot be a coroutine: 'std::experimental::coroutine_traits<DummyVoidTag>' has no member named 'promise_type'}}
- co_await a;
+ co_await a; // expected-warning {{Found deprecated std::experimental}}
}
template <typename... T>
Index: clang/test/SemaCXX/coroutine_handle-address-return-type-exp-namespace.cpp
===================================================================
--- clang/test/SemaCXX/coroutine_handle-address-return-type-exp-namespace.cpp
+++ clang/test/SemaCXX/coroutine_handle-address-return-type-exp-namespace.cpp
@@ -66,7 +66,7 @@
} a;
task f() {
- co_await a;
+ co_await a; // expected-warning {{Found deprecated std::experimental}}
}
int main() {
Index: clang/test/SemaCXX/coroutine-unhandled_exception-warning-exp-namespace.cpp
===================================================================
--- clang/test/SemaCXX/coroutine-unhandled_exception-warning-exp-namespace.cpp
+++ clang/test/SemaCXX/coroutine-unhandled_exception-warning-exp-namespace.cpp
@@ -5,7 +5,7 @@
// RUN: %clang_cc1 -triple x86_64-apple-darwin9 %s -std=c++14 -fcoroutines-ts \
// RUN: -fsyntax-only -Wignored-qualifiers -Wno-error=return-type -verify \
// RUN: -fblocks -Wno-unreachable-code -Wno-unused-value \
-// RUN: -DDISABLE_WARNING -Wno-coroutine-missing-unhandled-exception
+// RUN: -DDISABLE_WARNING -Wno-deprecated-coroutine -Wno-coroutine-missing-unhandled-exception
#if __has_feature(cxx_exceptions)
#error This test requires exceptions be disabled
@@ -32,7 +32,7 @@
#ifndef DISABLE_WARNING
void test0() { // expected-warning {{'promise_void' is required to declare the member 'unhandled_exception()' when exceptions are enabled}}
- co_return;
+ co_return; // expected-warning {{Found deprecated std::experimental}}
}
#else
void test0() { // expected-no-diagnostics
Index: clang/test/SemaCXX/coroutine-traits-undefined-template-exp-namespace.cpp
===================================================================
--- clang/test/SemaCXX/coroutine-traits-undefined-template-exp-namespace.cpp
+++ clang/test/SemaCXX/coroutine-traits-undefined-template-exp-namespace.cpp
@@ -16,4 +16,5 @@
void uses_forward_declaration() {
co_return; // expected-error {{this function cannot be a coroutine: missing definition of specialization 'coroutine_traits<void>'}}
+ // expected-warning@-1 {{Found deprecated std::experimental}}
}
Index: clang/test/SemaCXX/coroutine-seh-exp-namespace.cpp
===================================================================
--- clang/test/SemaCXX/coroutine-seh-exp-namespace.cpp
+++ clang/test/SemaCXX/coroutine-seh-exp-namespace.cpp
@@ -33,6 +33,7 @@
void SEH_used() {
__try { // expected-error {{cannot use SEH '__try' in a coroutine when C++ exceptions are enabled}}
co_return; // expected-note {{function is a coroutine due to use of 'co_return' here}}
+ // expected-warning@-1 {{Found deprecated std::experimental}}
} __except (0) {
}
}
Index: clang/test/SemaCXX/coroutine-rvo-exp-namespace.cpp
===================================================================
--- clang/test/SemaCXX/coroutine-rvo-exp-namespace.cpp
+++ clang/test/SemaCXX/coroutine-rvo-exp-namespace.cpp
@@ -62,7 +62,7 @@
task<NoCopyNoMove> local2val() {
NoCopyNoMove value;
- co_return value;
+ co_return value; // expected-warning {{Found deprecated std::experimental}}
}
task<NoCopyNoMove &> local2ref() {
Index: clang/test/SemaCXX/coroutine-final-suspend-noexcept-exp-namespace.cpp
===================================================================
--- clang/test/SemaCXX/coroutine-final-suspend-noexcept-exp-namespace.cpp
+++ clang/test/SemaCXX/coroutine-final-suspend-noexcept-exp-namespace.cpp
@@ -56,7 +56,7 @@
coro_t f(int n) { // expected-error {{the expression 'co_await __promise.final_suspend()' is required to be non-throwing}}
A a{};
- co_await a;
+ co_await a; // expected-warning {{Found deprecated std::experimental}}
}
template <typename T>
Index: clang/test/SemaCXX/coreturn-exp-namespace.cpp
===================================================================
--- clang/test/SemaCXX/coreturn-exp-namespace.cpp
+++ clang/test/SemaCXX/coreturn-exp-namespace.cpp
@@ -83,7 +83,7 @@
template <typename... T>
struct std::experimental::coroutine_traits<int, T...> { using promise_type = promise_int; };
-void test0() { co_await a; }
+void test0() { co_await a; } // expected-warning {{Found deprecated std::experimental}}
float test1() { co_await a; }
int test2() {
Index: clang/test/SemaCXX/coreturn-eh-exp-namespace.cpp
===================================================================
--- clang/test/SemaCXX/coreturn-eh-exp-namespace.cpp
+++ clang/test/SemaCXX/coreturn-eh-exp-namespace.cpp
@@ -1,5 +1,4 @@
// RUN: %clang_cc1 -triple x86_64-apple-darwin9 %s -std=c++14 -fcoroutines-ts -fcxx-exceptions -fsyntax-only -Wignored-qualifiers -Wno-error=return-type -verify -fblocks -Wall -Wextra -Wno-error=unreachable-code
-// expected-no-diagnostics
#include "Inputs/std-coroutine-exp-namespace.h"
@@ -40,7 +39,7 @@
VoidTagReturnValue test() {
object x = {};
try {
- co_return {};
+ co_return {}; // expected-warning {{Found deprecated std::experimental}}
} catch (...) {
throw;
}
Index: clang/test/SemaCXX/co_await-range-for-exp-namespace.cpp
===================================================================
--- clang/test/SemaCXX/co_await-range-for-exp-namespace.cpp
+++ clang/test/SemaCXX/co_await-range-for-exp-namespace.cpp
@@ -51,7 +51,7 @@
MyForLoopArrayAwaiter g() {
int arr[10] = {0};
for
- co_await(auto i : arr) {}
+ co_await(auto i : arr) {} // expected-warning {{Found deprecated std::experimental}}
// expected-error@-1 {{call to deleted member function 'await_transform'}}
// expected-note@-2 {{'await_transform' implicitly required by 'co_await' here}}
}
Index: clang/lib/Sema/SemaCoroutine.cpp
===================================================================
--- clang/lib/Sema/SemaCoroutine.cpp
+++ clang/lib/Sema/SemaCoroutine.cpp
@@ -1675,8 +1675,8 @@
<< "std::coroutine_traits";
return nullptr;
}
- /// TODO: Add a warning about not including <experimental/coroutine>
- /// once we update libcxx.
+ Diag(KwLoc, diag::warn_deprecated_coroutine_namespace)
+ << "coroutine_traits";
} else {
/// When we found coroutine_traits in std namespace. Make sure there is no
/// misleading definition in std::experimental namespace.
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===================================================================
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -11011,6 +11011,11 @@
"%0 type was not found; include <coroutine> before defining "
"a coroutine; include <experimental/coroutine> if your version "
"of libcxx is less than 14.0">;
+def warn_deprecated_coroutine_namespace : Warning <
+ "Found deprecated std::experimental::%0. Consider to update your libc++ "
+ "or move coroutine components into std namespace in case you are using "
+ "self-defined coroutine components">,
+ InGroup<DeprecatedCorotuine>;
def err_mixed_use_std_and_experimental_namespace_for_coroutine : Error <
"Found mixed use of std namespace and std::experimental namespace for "
"coroutine, which is disallowed. The coroutine components in "
Index: clang/include/clang/Basic/DiagnosticGroups.td
===================================================================
--- clang/include/clang/Basic/DiagnosticGroups.td
+++ clang/include/clang/Basic/DiagnosticGroups.td
@@ -54,7 +54,9 @@
CompoundTokenSplitBySpace]>;
def CoroutineMissingUnhandledException :
DiagGroup<"coroutine-missing-unhandled-exception">;
-def Coroutine : DiagGroup<"coroutine", [CoroutineMissingUnhandledException]>;
+def DeprecatedCorotuine :
+ DiagGroup<"deprecated-coroutine">;
+def Coroutine : DiagGroup<"coroutine", [CoroutineMissingUnhandledException, DeprecatedCorotuine]>;
def ObjCBoolConstantConversion : DiagGroup<"objc-bool-constant-conversion">;
def ConstantConversion : DiagGroup<"constant-conversion",
[BitFieldConstantConversion,
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits