[clang] 565c175 - [clang] Adjust coroutine namespace diagnostics

Nathan Sidwell via cfe-commits cfe-commits at lists.llvm.org
Mon Dec 20 08:51:16 PST 2021


Author: Nathan Sidwell
Date: 2021-12-20T08:50:16-08:00
New Revision: 565c17574dd062cf3096d578c4a2ab058f494c6d

URL: https://github.com/llvm/llvm-project/commit/565c17574dd062cf3096d578c4a2ab058f494c6d
DIFF: https://github.com/llvm/llvm-project/commit/565c17574dd062cf3096d578c4a2ab058f494c6d.diff

LOG: [clang] Adjust coroutine namespace diagnostics

The diagnostics concerning mixing std::experimental and std are
somewhat wordy and have some typographical errors.  Diagnostics do not
start with a capital letter nor end with a fullstop.  Usually we try
and link clauses with a semicolon, rather than start a new sentence.
So that's what this patch does.  Along with avoiding repetition about
std::experimental going away.

Differential Revision: https://reviews.llvm.org/D116026

Added: 
    

Modified: 
    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-mixed-exp-namespace.cpp
    clang/test/SemaCXX/coroutine-mixed2-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

Removed: 
    


################################################################################
diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 29e7c5b447140..c26dbbbf1f697 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -11040,14 +11040,12 @@ def err_implied_coroutine_type_not_found : Error<
   "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.">,
+  "support for std::experimental::%0 will be removed in LLVM 15; "
+  "use std::%0 instead">,
   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 "
-  "std::experimental namespace is deprecated. Please use coroutine components "
-  "under std namespace.">;
+def err_mixed_use_std_and_experimental_namespace_for_coroutine : Error<
+  "mixed use of std and std::experimental namespaces for "
+  "coroutine components">;
 def err_implicit_coroutine_std_nothrow_type_not_found : Error<
   "std::nothrow was not found; include <new> before defining a coroutine which "
   "uses get_return_object_on_allocation_failure()">;

diff  --git a/clang/lib/Sema/SemaCoroutine.cpp b/clang/lib/Sema/SemaCoroutine.cpp
index b999b08d1662b..d4a919e8c1656 100644
--- a/clang/lib/Sema/SemaCoroutine.cpp
+++ b/clang/lib/Sema/SemaCoroutine.cpp
@@ -1687,6 +1687,8 @@ ClassTemplateDecl *Sema::lookupCoroutineTraits(SourceLocation KwLoc,
       if (ExpNamespace && LookupQualifiedName(ExpResult, ExpNamespace)) {
         Diag(KwLoc,
              diag::err_mixed_use_std_and_experimental_namespace_for_coroutine);
+        Diag(KwLoc, diag::warn_deprecated_coroutine_namespace)
+            << "coroutine_traits";
         return nullptr;
       }
     }

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 46073ae60f729..75568505ab552 100644
--- a/clang/test/SemaCXX/co_await-range-for-exp-namespace.cpp
+++ b/clang/test/SemaCXX/co_await-range-for-exp-namespace.cpp
@@ -50,7 +50,7 @@ struct MyForLoopArrayAwaiter {
 };
 MyForLoopArrayAwaiter g() {
   int arr[10] = {0};
-  for co_await (auto i : arr) {} // expected-warning {{Please move from std::experimental::coroutine_traits to std::coroutine_traits}}
+  for co_await (auto i : arr) {} // expected-warning {{support for std::experimental::coroutine_traits will be removed}}
   // expected-error at -1 {{call to deleted member function 'await_transform'}}
   // expected-note at -2 {{'await_transform' implicitly required by 'co_await' here}}
 }

diff  --git a/clang/test/SemaCXX/coreturn-eh-exp-namespace.cpp b/clang/test/SemaCXX/coreturn-eh-exp-namespace.cpp
index ae36dbbf0fc99..7d85c924f6690 100644
--- a/clang/test/SemaCXX/coreturn-eh-exp-namespace.cpp
+++ b/clang/test/SemaCXX/coreturn-eh-exp-namespace.cpp
@@ -39,7 +39,7 @@ struct std::experimental::coroutine_traits<void, T1> { using promise_type = prom
 VoidTagReturnValue test() {
   object x = {};
   try {
-    co_return {}; // expected-warning {{Please move from std::experimental::coroutine_traits to std::coroutine_traits}}
+    co_return {}; // expected-warning {{support for std::experimental::coroutine_traits will be removed}}
   } catch (...) {
     throw;
   }

diff  --git a/clang/test/SemaCXX/coreturn-exp-namespace.cpp b/clang/test/SemaCXX/coreturn-exp-namespace.cpp
index 70559c164b8ee..c4023c2a94fa8 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; } // expected-warning {{Please move from std::experimental::coroutine_traits to std::coroutine_traits}}
+void test0() { co_await a; } // expected-warning {{support for std::experimental::coroutine_traits will be removed}}
 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 7254e1adbb715..5e4e4802eb487 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; // expected-warning {{Please move from std::experimental::coroutine_traits to std::coroutine_traits}}
+  co_await a; // expected-warning {{support for std::experimental::coroutine_traits will be removed}}
 }
 
 template <typename T>

diff  --git a/clang/test/SemaCXX/coroutine-mixed-exp-namespace.cpp b/clang/test/SemaCXX/coroutine-mixed-exp-namespace.cpp
index 5d1e687d5bd8f..8f64573551906 100644
--- a/clang/test/SemaCXX/coroutine-mixed-exp-namespace.cpp
+++ b/clang/test/SemaCXX/coroutine-mixed-exp-namespace.cpp
@@ -1,5 +1,5 @@
 // This file is to test the mixed use of `std::experimental::coroutine*` and `std::coroutine*`
-// wouldn't make the compliler to crash and emit the diagnostic message correctly.
+// wouldn't make the compiler to crash and emit the diagnostic message correctly.
 // RUN: %clang_cc1 -verify -std=c++20 -fsyntax-only %s
 
 #include "Inputs/std-coroutine-exp-namespace.h"
@@ -23,5 +23,6 @@ template <>
 struct std::coroutine_traits<void> { using promise_type = promise_void; };
 
 void test() {
-  co_return; // expected-error {{Found mixed use of std namespace and std::experimental namespace for coroutine, which is disallowed. The coroutine components in std::experimental namespace is deprecated. Please use coroutine components under std namespace.}}
+  co_return; // expected-error {{mixed use of std and std::experimental namespaces for coroutine components}}
+  // expected-warning at -1{{support for std::experimental::coroutine_traits will be removed}}
 }

diff  --git a/clang/test/SemaCXX/coroutine-mixed2-exp-namespace.cpp b/clang/test/SemaCXX/coroutine-mixed2-exp-namespace.cpp
index 95f882c5294f6..67cb42afa90df 100644
--- a/clang/test/SemaCXX/coroutine-mixed2-exp-namespace.cpp
+++ b/clang/test/SemaCXX/coroutine-mixed2-exp-namespace.cpp
@@ -24,5 +24,6 @@ template <>
 struct std::coroutine_traits<void> { using promise_type = promise_void; };
 
 void test() {
-  co_return; // expected-error {{Found mixed use of std namespace and std::experimental namespace for coroutine, which is disallowed. The coroutine components in std::experimental namespace is deprecated. Please use coroutine components under std namespace.}}
+  co_return; // expected-error {{mixed use of std and std::experimental namespaces for coroutine components}}
+  // expected-warning at -1{{support for std::experimental::coroutine_traits will be removed}}
 }

diff  --git a/clang/test/SemaCXX/coroutine-rvo-exp-namespace.cpp b/clang/test/SemaCXX/coroutine-rvo-exp-namespace.cpp
index 251ad8e352c8a..f73ff3880c046 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; // expected-warning {{Please move from std::experimental::coroutine_traits to std::coroutine_traits}}
+  co_return value; // expected-warning {{support for std::experimental::coroutine_traits will be removed}}
 }
 
 task<NoCopyNoMove &> local2ref() {

diff  --git a/clang/test/SemaCXX/coroutine-seh-exp-namespace.cpp b/clang/test/SemaCXX/coroutine-seh-exp-namespace.cpp
index ace3d653b8457..9384397687dba 100644
--- a/clang/test/SemaCXX/coroutine-seh-exp-namespace.cpp
+++ b/clang/test/SemaCXX/coroutine-seh-exp-namespace.cpp
@@ -33,7 +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 at -1 {{Please move from std::experimental::coroutine_traits to std::coroutine_traits}}
+               // expected-warning at -1 {{support for std::experimental::coroutine_traits will be removed}}
   } __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 8a79c35703453..649249f814d4e 100644
--- a/clang/test/SemaCXX/coroutine-traits-undefined-template-exp-namespace.cpp
+++ b/clang/test/SemaCXX/coroutine-traits-undefined-template-exp-namespace.cpp
@@ -16,5 +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 at -1 {{Please move from std::experimental::coroutine_traits to std::coroutine_traits}}
+             // expected-warning at -1 {{support for std::experimental::coroutine_traits will be removed}}
 }

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 b4c4a0eb9a298..76d5ae87e3658 100644
--- a/clang/test/SemaCXX/coroutine-unhandled_exception-warning-exp-namespace.cpp
+++ b/clang/test/SemaCXX/coroutine-unhandled_exception-warning-exp-namespace.cpp
@@ -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;   // expected-warning {{Please move from std::experimental::coroutine_traits to std::coroutine_traits}}
+  co_return;   // expected-warning {{support for std::experimental::coroutine_traits will be removed}}
 }
 #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 7cc47cbb52566..c722495db3902 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; // expected-warning {{Please move from std::experimental::coroutine_traits to std::coroutine_traits}}
+  co_await a; // expected-warning {{support for std::experimental::coroutine_traits will be removed}}
 }
 
 int main() {

diff  --git a/clang/test/SemaCXX/coroutines-exp-namespace.cpp b/clang/test/SemaCXX/coroutines-exp-namespace.cpp
index 1a1537a0ea1c5..6fce00c09ca6f 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;                      // expected-warning {{Please move from std::experimental::coroutine_traits to std::coroutine_traits}}
+  co_await a;                      // expected-warning {{support for std::experimental::coroutine_traits will be removed}}
 }
 
 template <typename... T>


        


More information about the cfe-commits mailing list