]> granicus.if.org Git - clang/commitdiff
[coroutines] Do not attempt to typo-correct when coroutine is looking for required...
authorGor Nishanov <GorNishanov@gmail.com>
Tue, 27 Mar 2018 20:38:19 +0000 (20:38 +0000)
committerGor Nishanov <GorNishanov@gmail.com>
Tue, 27 Mar 2018 20:38:19 +0000 (20:38 +0000)
When SemaCoroutine looks for await_resume, it means it. No need for helpful: "Did you mean await_ready?" messages.

Fixes PR33477 and a couple of FIXMEs in test/SemaCXX/coroutines.cpp

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@328663 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaCoroutine.cpp
test/SemaCXX/coroutines.cpp

index 95758baff4a05ac99d9b655581d30efd2e2953eb..139a21014d1dd29f9d8be68d9f94c0e3753a1a3a 100644 (file)
@@ -362,6 +362,15 @@ static ExprResult buildMemberCall(Sema &S, Expr *Base, SourceLocation Loc,
   if (Result.isInvalid())
     return ExprError();
 
+  // We meant exactly what we asked for. No need for typo correction.
+  if (auto *TE = dyn_cast<TypoExpr>(Result.get())) {
+    S.clearDelayedTypo(TE);
+    S.Diag(Loc, diag::err_no_member)
+        << NameInfo.getName() << Base->getType()->getAsCXXRecordDecl()
+        << Base->getSourceRange();
+    return ExprError();
+  }
+
   return S.ActOnCallExpr(nullptr, Result.get(), Loc, Args, Loc, nullptr);
 }
 
index c09ca570636c3de6ace4513322f1ed1a4080dd44..ed8fd909eb980476a5f85ff87af0b4a203d964cd 100644 (file)
@@ -510,8 +510,7 @@ coro<bad_promise_1> missing_get_return_object() { // expected-error {{no member
 
 struct bad_promise_2 {
   coro<bad_promise_2> get_return_object();
-  // FIXME: We shouldn't offer a typo-correction here!
-  suspend_always final_suspend(); // expected-note {{here}}
+  suspend_always final_suspend();
   void unhandled_exception();
   void return_void();
 };
@@ -522,8 +521,7 @@ coro<bad_promise_2> missing_initial_suspend() { // expected-error {{no member na
 
 struct bad_promise_3 {
   coro<bad_promise_3> get_return_object();
-  // FIXME: We shouldn't offer a typo-correction here!
-  suspend_always initial_suspend(); // expected-note {{here}}
+  suspend_always initial_suspend();
   void unhandled_exception();
   void return_void();
 };
@@ -1378,3 +1376,22 @@ test_unused_warning() {
   co_await awaitable_unused_warn(); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
   co_yield 42; // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
 }
+
+struct missing_await_ready {
+  void await_suspend(std::experimental::coroutine_handle<>);
+  void await_resume();
+};
+struct missing_await_suspend {
+  bool await_ready();
+  void await_resume();
+};
+struct missing_await_resume {
+  bool await_ready();
+  void await_suspend(std::experimental::coroutine_handle<>);
+};
+
+void test_missing_awaitable_members() {
+  co_await missing_await_ready{}; // expected-error {{no member named 'await_ready' in 'missing_await_ready'}}
+  co_await missing_await_suspend{}; // expected-error {{no member named 'await_suspend' in 'missing_await_suspend'}}
+  co_await missing_await_resume{}; // expected-error {{no member named 'await_resume' in 'missing_await_resume'}}
+}