]> granicus.if.org Git - clang/commitdiff
[coroutines] Improved diagnostics when unhandled_exception is missing in the promise_type
authorGor Nishanov <GorNishanov@gmail.com>
Wed, 24 May 2017 14:34:19 +0000 (14:34 +0000)
committerGor Nishanov <GorNishanov@gmail.com>
Wed, 24 May 2017 14:34:19 +0000 (14:34 +0000)
Summary: Now we helpfully provide a note pointing at the promise_type in question.

Reviewers: EricWF, GorNishanov

Reviewed By: GorNishanov

Subscribers: cfe-commits

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

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

lib/Sema/SemaCoroutine.cpp
test/SemaCXX/coroutine-unhandled_exception-warning.cpp
test/SemaCXX/coroutines.cpp

index 857dcda4e6e4d22d293397729e0fe37e9cb72159..b02196500d9bf86046c178ff4d5e5de3ebf16647 100644 (file)
@@ -120,8 +120,7 @@ static QualType lookupPromiseType(Sema &S, const FunctionProtoType *FnType,
   return PromiseType;
 }
 
-/// Look up the std::coroutine_traits<...>::promise_type for the given
-/// function type.
+/// Look up the std::experimental::coroutine_handle<PromiseType>.
 static QualType lookupCoroutineHandleType(Sema &S, QualType PromiseType,
                                           SourceLocation Loc) {
   if (PromiseType.isNull())
@@ -729,8 +728,7 @@ void Sema::CheckCompletedCoroutineBody(FunctionDecl *FD, Stmt *&Body) {
   }
 
   if (isa<CoroutineBodyStmt>(Body)) {
-    // FIXME(EricWF): Nothing todo. the body is already a transformed coroutine
-    // body statement.
+    // Nothing todo. the body is already a transformed coroutine body statement.
     return;
   }
 
@@ -1030,6 +1028,8 @@ bool CoroutineStmtBuilder::makeOnException() {
             : diag::
                   warn_coroutine_promise_unhandled_exception_required_with_exceptions;
     S.Diag(Loc, DiagID) << PromiseRecordDecl;
+    S.Diag(PromiseRecordDecl->getLocation(), diag::note_defined_here)
+        << PromiseRecordDecl;
     return !RequireUnhandledException;
   }
 
index d7f6066109a5fe1e1dee1432ad4237be57a547a8..d819580462c8e85963ab861d7dbd96335821f4e4 100644 (file)
 using std::experimental::suspend_always;
 using std::experimental::suspend_never;
 
+#ifndef DISABLE_WARNING
+struct promise_void { // expected-note {{defined here}}
+#else
 struct promise_void {
+#endif
   void get_return_object();
   suspend_always initial_suspend();
   suspend_always final_suspend();
index 3e33c99881a7a6e13f6c273972f81f8a0d5bf2ce..a39ad1b40165410e562095f133b395044f7d0c35 100644 (file)
@@ -540,7 +540,7 @@ coro<T> bad_implicit_return_dependent(T) { // expected-error {{'bad_promise_6' d
 }
 template coro<bad_promise_6> bad_implicit_return_dependent(bad_promise_6); // expected-note {{in instantiation}}
 
-struct bad_promise_7 {
+struct bad_promise_7 { // expected-note 2 {{defined here}}
   coro<bad_promise_7> get_return_object();
   suspend_always initial_suspend();
   suspend_always final_suspend();