Author: gornishanov Date: Wed May 24 09:34:19 2017 New Revision: 303752 URL: http://llvm.org/viewvc/llvm-project?rev=303752&view=rev Log: [coroutines] Improved diagnostics when unhandled_exception is missing in the promise_type
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 Modified: cfe/trunk/lib/Sema/SemaCoroutine.cpp cfe/trunk/test/SemaCXX/coroutine-unhandled_exception-warning.cpp cfe/trunk/test/SemaCXX/coroutines.cpp Modified: cfe/trunk/lib/Sema/SemaCoroutine.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCoroutine.cpp?rev=303752&r1=303751&r2=303752&view=diff ============================================================================== --- cfe/trunk/lib/Sema/SemaCoroutine.cpp (original) +++ cfe/trunk/lib/Sema/SemaCoroutine.cpp Wed May 24 09:34:19 2017 @@ -120,8 +120,7 @@ static QualType lookupPromiseType(Sema & 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(F } 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::makeOnExcepti : 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; } Modified: cfe/trunk/test/SemaCXX/coroutine-unhandled_exception-warning.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/coroutine-unhandled_exception-warning.cpp?rev=303752&r1=303751&r2=303752&view=diff ============================================================================== --- cfe/trunk/test/SemaCXX/coroutine-unhandled_exception-warning.cpp (original) +++ cfe/trunk/test/SemaCXX/coroutine-unhandled_exception-warning.cpp Wed May 24 09:34:19 2017 @@ -16,7 +16,11 @@ 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(); Modified: cfe/trunk/test/SemaCXX/coroutines.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/coroutines.cpp?rev=303752&r1=303751&r2=303752&view=diff ============================================================================== --- cfe/trunk/test/SemaCXX/coroutines.cpp (original) +++ cfe/trunk/test/SemaCXX/coroutines.cpp Wed May 24 09:34:19 2017 @@ -540,7 +540,7 @@ coro<T> bad_implicit_return_dependent(T) } 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(); _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits