summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChuanqi Xu <yedeng.yd@linux.alibaba.com>2021-11-18 09:34:58 +0800
committerChuanqi Xu <yedeng.yd@linux.alibaba.com>2021-11-18 09:41:01 +0800
commitaf9f3c6d86b4afc93fb0a29ee430fc42f593800f (patch)
treef10a040874d5684140f2d886502e58a5658b8d85
parent6e41a0691132482478c4e82d0610fe19a4128f74 (diff)
downloadllvm-af9f3c6d86b4afc93fb0a29ee430fc42f593800f.tar.gz
[Coroutine] Warn deprecated 'std::experimental::coro' uses
Since we've decided the to not support std::experimental::coroutine*, we should tell the user they need to update. Reviewed By: Quuxplusone, ldionne, Mordante Differential Revision: https://reviews.llvm.org/D113977
-rw-r--r--clang/include/clang/Basic/DiagnosticGroups.td4
-rw-r--r--clang/include/clang/Basic/DiagnosticSemaKinds.td4
-rw-r--r--clang/lib/Sema/SemaCoroutine.cpp4
-rw-r--r--clang/test/SemaCXX/co_await-range-for-exp-namespace.cpp21
-rw-r--r--clang/test/SemaCXX/coreturn-eh-exp-namespace.cpp3
-rw-r--r--clang/test/SemaCXX/coreturn-exp-namespace.cpp2
-rw-r--r--clang/test/SemaCXX/coroutine-final-suspend-noexcept-exp-namespace.cpp2
-rw-r--r--clang/test/SemaCXX/coroutine-mixed2-exp-namespace.cpp2
-rw-r--r--clang/test/SemaCXX/coroutine-rvo-exp-namespace.cpp2
-rw-r--r--clang/test/SemaCXX/coroutine-seh-exp-namespace.cpp1
-rw-r--r--clang/test/SemaCXX/coroutine-traits-undefined-template-exp-namespace.cpp1
-rw-r--r--clang/test/SemaCXX/coroutine-unhandled_exception-warning-exp-namespace.cpp4
-rw-r--r--clang/test/SemaCXX/coroutine_handle-address-return-type-exp-namespace.cpp2
-rw-r--r--clang/test/SemaCXX/coroutines-exp-namespace.cpp2
-rw-r--r--libcxx/test/libcxx/experimental/language.support/support.coroutines/dialect_support.pass.cpp2
-rw-r--r--libcxx/test/std/experimental/language.support/support.coroutines/lit.local.cfg1
16 files changed, 29 insertions, 28 deletions
diff --git a/clang/include/clang/Basic/DiagnosticGroups.td b/clang/include/clang/Basic/DiagnosticGroups.td
index 60d417fd5770..85d373845c81 100644
--- a/clang/include/clang/Basic/DiagnosticGroups.td
+++ b/clang/include/clang/Basic/DiagnosticGroups.td
@@ -54,7 +54,9 @@ def CompoundTokenSplit : DiagGroup<"compound-token-split",
CompoundTokenSplitBySpace]>;
def CoroutineMissingUnhandledException :
DiagGroup<"coroutine-missing-unhandled-exception">;
-def Coroutine : DiagGroup<"coroutine", [CoroutineMissingUnhandledException]>;
+def DeprecatedExperimentalCoroutine :
+ DiagGroup<"deprecated-experimental-coroutine">;
+def Coroutine : DiagGroup<"coroutine", [CoroutineMissingUnhandledException, DeprecatedExperimentalCoroutine]>;
def ObjCBoolConstantConversion : DiagGroup<"objc-bool-constant-conversion">;
def ConstantConversion : DiagGroup<"constant-conversion",
[BitFieldConstantConversion,
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 76d4f9286d37..50c1e0a1746b 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -11011,6 +11011,10 @@ def err_implied_coroutine_type_not_found : Error<
"%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<
+ "Please move from std::experimental::%0 to std::%0. "
+ "Support for std::experimental::%0 will be removed in LLVM 15.">,
+ InGroup<DeprecatedExperimentalCoroutine>;
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 "
diff --git a/clang/lib/Sema/SemaCoroutine.cpp b/clang/lib/Sema/SemaCoroutine.cpp
index 323e425585ce..b999b08d1662 100644
--- a/clang/lib/Sema/SemaCoroutine.cpp
+++ b/clang/lib/Sema/SemaCoroutine.cpp
@@ -1675,8 +1675,8 @@ ClassTemplateDecl *Sema::lookupCoroutineTraits(SourceLocation KwLoc,
<< "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.
diff --git a/clang/test/SemaCXX/co_await-range-for-exp-namespace.cpp b/clang/test/SemaCXX/co_await-range-for-exp-namespace.cpp
index daf78b02ca87..46073ae60f72 100644
--- a/clang/test/SemaCXX/co_await-range-for-exp-namespace.cpp
+++ b/clang/test/SemaCXX/co_await-range-for-exp-namespace.cpp
@@ -50,8 +50,7 @@ struct MyForLoopArrayAwaiter {
};
MyForLoopArrayAwaiter g() {
int arr[10] = {0};
- for
- co_await(auto i : arr) {}
+ for co_await (auto i : arr) {} // expected-warning {{Please move from std::experimental::coroutine_traits to std::coroutine_traits}}
// expected-error@-1 {{call to deleted member function 'await_transform'}}
// expected-note@-2 {{'await_transform' implicitly required by 'co_await' here}}
}
@@ -73,16 +72,14 @@ struct ForLoopAwaiterBadBeginTransform {
};
ForLoopAwaiterBadBeginTransform bad_begin() {
Range<int> R;
- for
- co_await(auto i : R) {}
+ for co_await (auto i : R) {}
// expected-error@-1 {{call to deleted member function 'await_transform'}}
// expected-note@-2 {{'await_transform' implicitly required by 'co_await' here}}
}
template <class Dummy>
ForLoopAwaiterBadBeginTransform bad_begin_template(Dummy) {
Range<Dummy> R;
- for
- co_await(auto i : R) {}
+ for co_await (auto i : R) {}
// expected-error@-1 {{call to deleted member function 'await_transform'}}
// expected-note@-2 {{'await_transform' implicitly required by 'co_await' here}}
}
@@ -109,8 +106,7 @@ struct ForLoopAwaiterBadIncTransform {
};
ForLoopAwaiterBadIncTransform bad_inc_transform() {
Range<float> R;
- for
- co_await(auto i : R) {}
+ for co_await (auto i : R) {}
// expected-error@-1 {{overload resolution selected deleted operator 'co_await'}}
// expected-note@-2 {{in implicit call to 'operator++' for iterator of type 'Range<float>'}}
}
@@ -118,8 +114,7 @@ ForLoopAwaiterBadIncTransform bad_inc_transform() {
template <class Dummy>
ForLoopAwaiterBadIncTransform bad_inc_transform_template(Dummy) {
Range<Dummy> R;
- for
- co_await(auto i : R) {}
+ for co_await (auto i : R) {}
// expected-error@-1 {{overload resolution selected deleted operator 'co_await'}}
// expected-note@-2 {{in implicit call to 'operator++' for iterator of type 'Range<long>'}}
}
@@ -130,8 +125,7 @@ template ForLoopAwaiterBadIncTransform bad_inc_transform_template(long); // expe
template <class T>
constexpr void never_instant(T) {
static_assert(sizeof(T) != sizeof(T), "function should not be instantiated");
- for
- co_await(auto i : foo(T{})) {}
+ for co_await (auto i : foo(T{})) {}
// expected-error@-1 {{'co_await' cannot be used in a constexpr function}}
}
@@ -155,8 +149,7 @@ using NS::ForLoopAwaiterCoawaitLookup;
template <class T>
ForLoopAwaiterCoawaitLookup test_coawait_lookup(T) {
Range<T> R;
- for
- co_await(auto i : R) {}
+ for co_await (auto i : R) {}
// expected-error@-1 {{no member named 'await_ready' in 'CoawaitTag<Iter<int>, false>'}}
}
template ForLoopAwaiterCoawaitLookup test_coawait_lookup(int); // expected-note {{requested here}}
diff --git a/clang/test/SemaCXX/coreturn-eh-exp-namespace.cpp b/clang/test/SemaCXX/coreturn-eh-exp-namespace.cpp
index d49e23ad31e2..ae36dbbf0fc9 100644
--- a/clang/test/SemaCXX/coreturn-eh-exp-namespace.cpp
+++ b/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 @@ struct std::experimental::coroutine_traits<void, T1> { using promise_type = prom
VoidTagReturnValue test() {
object x = {};
try {
- co_return {};
+ co_return {}; // expected-warning {{Please move from std::experimental::coroutine_traits to std::coroutine_traits}}
} catch (...) {
throw;
}
diff --git a/clang/test/SemaCXX/coreturn-exp-namespace.cpp b/clang/test/SemaCXX/coreturn-exp-namespace.cpp
index c7fe212daed3..70559c164b8e 100644
--- a/clang/test/SemaCXX/coreturn-exp-namespace.cpp
+++ b/clang/test/SemaCXX/coreturn-exp-namespace.cpp
@@ -83,7 +83,7 @@ struct std::experimental::coroutine_traits<float, T...> { using promise_type = p
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 {{Please move from std::experimental::coroutine_traits to std::coroutine_traits}}
float test1() { co_await a; }
int test2() {
diff --git a/clang/test/SemaCXX/coroutine-final-suspend-noexcept-exp-namespace.cpp b/clang/test/SemaCXX/coroutine-final-suspend-noexcept-exp-namespace.cpp
index 92bb91be93a1..7254e1adbb71 100644
--- a/clang/test/SemaCXX/coroutine-final-suspend-noexcept-exp-namespace.cpp
+++ b/clang/test/SemaCXX/coroutine-final-suspend-noexcept-exp-namespace.cpp
@@ -56,7 +56,7 @@ struct coro_t {
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 {{Please move from std::experimental::coroutine_traits to std::coroutine_traits}}
}
template <typename T>
diff --git a/clang/test/SemaCXX/coroutine-mixed2-exp-namespace.cpp b/clang/test/SemaCXX/coroutine-mixed2-exp-namespace.cpp
index dcccd2b62e0c..95f882c5294f 100644
--- a/clang/test/SemaCXX/coroutine-mixed2-exp-namespace.cpp
+++ b/clang/test/SemaCXX/coroutine-mixed2-exp-namespace.cpp
@@ -1,4 +1,4 @@
-// This file is to test the mixed use of `std::experimental::coroutine*` and `std::coroutine*`
+// This file is to test the mixed use of `std::experimental::coroutine_traits` and `std::coroutine_traits`
// which is similar to coroutine-mixed-exp-namesapce. This file tests the relative order of
// included header wouldn't affect the diagnostic messages.
// RUN: %clang_cc1 -verify -std=c++20 -fsyntax-only %s
diff --git a/clang/test/SemaCXX/coroutine-rvo-exp-namespace.cpp b/clang/test/SemaCXX/coroutine-rvo-exp-namespace.cpp
index c65094c2e513..251ad8e352c8 100644
--- a/clang/test/SemaCXX/coroutine-rvo-exp-namespace.cpp
+++ b/clang/test/SemaCXX/coroutine-rvo-exp-namespace.cpp
@@ -62,7 +62,7 @@ struct task {
task<NoCopyNoMove> local2val() {
NoCopyNoMove value;
- co_return value;
+ co_return value; // expected-warning {{Please move from std::experimental::coroutine_traits to std::coroutine_traits}}
}
task<NoCopyNoMove &> local2ref() {
diff --git a/clang/test/SemaCXX/coroutine-seh-exp-namespace.cpp b/clang/test/SemaCXX/coroutine-seh-exp-namespace.cpp
index cc5fce9fae7f..ace3d653b845 100644
--- a/clang/test/SemaCXX/coroutine-seh-exp-namespace.cpp
+++ b/clang/test/SemaCXX/coroutine-seh-exp-namespace.cpp
@@ -33,6 +33,7 @@ template <> struct std::experimental::coroutine_traits<void> {
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 {{Please move from std::experimental::coroutine_traits to std::coroutine_traits}}
} __except (0) {
}
}
diff --git a/clang/test/SemaCXX/coroutine-traits-undefined-template-exp-namespace.cpp b/clang/test/SemaCXX/coroutine-traits-undefined-template-exp-namespace.cpp
index 4179d20f4491..8a79c3570345 100644
--- a/clang/test/SemaCXX/coroutine-traits-undefined-template-exp-namespace.cpp
+++ b/clang/test/SemaCXX/coroutine-traits-undefined-template-exp-namespace.cpp
@@ -16,4 +16,5 @@ template <> struct coroutine_traits<void>; // expected-note {{forward declaratio
void uses_forward_declaration() {
co_return; // expected-error {{this function cannot be a coroutine: missing definition of specialization 'coroutine_traits<void>'}}
+ // expected-warning@-1 {{Please move from std::experimental::coroutine_traits to std::coroutine_traits}}
}
diff --git a/clang/test/SemaCXX/coroutine-unhandled_exception-warning-exp-namespace.cpp b/clang/test/SemaCXX/coroutine-unhandled_exception-warning-exp-namespace.cpp
index 5394ae78d098..b4c4a0eb9a29 100644
--- a/clang/test/SemaCXX/coroutine-unhandled_exception-warning-exp-namespace.cpp
+++ b/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-experimental-coroutine -Wno-coroutine-missing-unhandled-exception
#if __has_feature(cxx_exceptions)
#error This test requires exceptions be disabled
@@ -32,7 +32,7 @@ struct std::experimental::coroutine_traits<void, T...> { using promise_type = pr
#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 {{Please move from std::experimental::coroutine_traits to std::coroutine_traits}}
}
#else
void test0() { // expected-no-diagnostics
diff --git a/clang/test/SemaCXX/coroutine_handle-address-return-type-exp-namespace.cpp b/clang/test/SemaCXX/coroutine_handle-address-return-type-exp-namespace.cpp
index a95138365234..7cc47cbb5256 100644
--- a/clang/test/SemaCXX/coroutine_handle-address-return-type-exp-namespace.cpp
+++ b/clang/test/SemaCXX/coroutine_handle-address-return-type-exp-namespace.cpp
@@ -66,7 +66,7 @@ struct awaitable {
} a;
task f() {
- co_await a;
+ co_await a; // expected-warning {{Please move from std::experimental::coroutine_traits to std::coroutine_traits}}
}
int main() {
diff --git a/clang/test/SemaCXX/coroutines-exp-namespace.cpp b/clang/test/SemaCXX/coroutines-exp-namespace.cpp
index 4ea0c66c5b34..cb32ac2d3a8a 100644
--- a/clang/test/SemaCXX/coroutines-exp-namespace.cpp
+++ b/clang/test/SemaCXX/coroutines-exp-namespace.cpp
@@ -83,7 +83,7 @@ struct auto_await_suspend {
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 {{Please move from std::experimental::coroutine_traits to std::coroutine_traits}}
}
template <typename... T>
diff --git a/libcxx/test/libcxx/experimental/language.support/support.coroutines/dialect_support.pass.cpp b/libcxx/test/libcxx/experimental/language.support/support.coroutines/dialect_support.pass.cpp
index 5f8fe52c2c4b..c237ca0585ac 100644
--- a/libcxx/test/libcxx/experimental/language.support/support.coroutines/dialect_support.pass.cpp
+++ b/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
diff --git a/libcxx/test/std/experimental/language.support/support.coroutines/lit.local.cfg b/libcxx/test/std/experimental/language.support/support.coroutines/lit.local.cfg
index d32e99fc2721..223de62e9fba 100644
--- a/libcxx/test/std/experimental/language.support/support.coroutines/lit.local.cfg
+++ b/libcxx/test/std/experimental/language.support/support.coroutines/lit.local.cfg
@@ -5,3 +5,4 @@ if 'fcoroutines-ts' not in config.available_features:
config.unsupported = True
else:
config.test_format.addCompileFlags(config, '-fcoroutines-ts')
+ config.test_format.addCompileFlags(config, '-Wno-coroutine')