[PATCH] D25349: [coroutines] Build fallthrough and set_exception statements.

Eric Fiselier via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 6 15:26:49 PDT 2016


EricWF created this revision.
EricWF added reviewers: rsmith, GorNishanov, majnemer.
EricWF added a subscriber: cfe-commits.
Herald added a subscriber: mehdi_amini.

This patch adds semantic checking and building of the fall-through `co_return;` statement as well as the `p.set_exception(std::current_exception())` call for handling uncaught exceptions.

The fall-through statement is built and checked according to:

> [dcl.fct.def.coroutine]/4
>  The unqualified-ids return_void and return_value are looked up in the scope of class P. If
>  both are found, the program is ill-formed. If the unqualified-id return_void is found, flowing
>  off the end of a coroutine is equivalent to a co_return with no operand. Otherwise, flowing off
>  the end of a coroutine results in undefined behavior.

Similarly the `set_exception` call is only built when that unqualified-id is found in the scope of class P.

Additionally this patch adds fall-through warnings for non-void returning coroutines. Since it's surprising undefined behavior I thought it would be important to add the warning right away.


https://reviews.llvm.org/D25349

Files:
  include/clang/AST/StmtCXX.h
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/AnalysisBasedWarnings.cpp
  lib/Sema/SemaCoroutine.cpp
  lib/Sema/TreeTransform.h
  test/SemaCXX/coreturn.cpp
  test/SemaCXX/coroutines.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D25349.73859.patch
Type: text/x-patch
Size: 14924 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20161006/4407a772/attachment-0001.bin>


More information about the cfe-commits mailing list