diff options
author | Eric Fiselier <eric@efcs.ca> | 2017-05-25 14:59:39 +0000 |
---|---|---|
committer | Eric Fiselier <eric@efcs.ca> | 2017-05-25 14:59:39 +0000 |
commit | 2640abdd4d882ec76a2f2cc97949e5b1394605ab (patch) | |
tree | c095b75442b719a98d13acb5a4e2e9898f27c18b /include/clang/Basic/DiagnosticSemaKinds.td | |
parent | 37a1cf7528130751151a50d8ecdeb370da3539e2 (diff) |
[coroutines] Diagnose when promise types fail to declare either return_void or return_value.
Summary:
According to the PDTS it's perfectly legal to have a promise type that defines neither `return_value` nor `return_void`. However a coroutine that uses such a promise type will almost always have UB, because it can never `co_return`.
This patch changes Clang to diagnose such cases as an error. It also cleans up some of the diagnostic messages relating to member lookup in the promise type.
Reviewers: GorNishanov, rsmith
Reviewed By: GorNishanov
Subscribers: cfe-commits
Differential Revision: https://reviews.llvm.org/D33534
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@303868 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/Basic/DiagnosticSemaKinds.td')
-rw-r--r-- | include/clang/Basic/DiagnosticSemaKinds.td | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/include/clang/Basic/DiagnosticSemaKinds.td b/include/clang/Basic/DiagnosticSemaKinds.td index 60039fac6e..81eea5e683 100644 --- a/include/clang/Basic/DiagnosticSemaKinds.td +++ b/include/clang/Basic/DiagnosticSemaKinds.td @@ -6303,6 +6303,8 @@ def warn_ambiguous_suitable_delete_function_found : Warning< InGroup<DiagGroup<"ambiguous-delete">>; def note_member_declared_here : Note< "member %0 declared here">; +def note_member_first_declared_here : Note< + "member %0 first declared here">; def err_decrement_bool : Error<"cannot decrement expression of type bool">; def warn_increment_bool : Warning< "incrementing expression of type bool is deprecated and " @@ -8918,8 +8920,6 @@ def err_return_in_coroutine : Error< "return statement not allowed in coroutine; did you mean 'co_return'?">; def note_declared_coroutine_here : Note< "function is a coroutine due to use of '%0' here">; -def note_promise_member_declared_here : Note< - "'%0' is declared here">; def err_coroutine_objc_method : Error< "Objective-C methods as coroutines are not yet supported">; def err_coroutine_unevaluated_context : Error< @@ -8954,8 +8954,10 @@ def err_coroutine_promise_type_incomplete : Error< def err_coroutine_type_missing_specialization : Error< "this function cannot be a coroutine: missing definition of " "specialization %q0">; -def err_coroutine_promise_return_ill_formed : Error< - "%0 declares both 'return_value' and 'return_void'">; +def err_coroutine_promise_incompatible_return_functions : Error< + "the coroutine promise type %0 declares both 'return_value' and 'return_void'">; +def err_coroutine_promise_requires_return_function : Error< + "the coroutine promise type %0 must declare either 'return_value' or 'return_void'">; def note_coroutine_promise_implicit_await_transform_required_here : Note< "call to 'await_transform' implicitly required by 'co_await' here">; def note_coroutine_promise_suspend_implicitly_required : Note< |