[PATCH] D59076: [coroutines][PR40978] Emit error for co_yield within catch block

Gor Nishanov via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Mar 7 13:05:52 PST 2019


GorNishanov added inline comments.


================
Comment at: test/SemaCXX/coroutines.cpp:299-311
   // FIXME: The spec says this is ill-formed.
   void operator=(CtorDtor&) {
     co_yield 0; // expected-error {{'co_yield' cannot be used in a copy assignment operator}}
   }
   void operator=(CtorDtor const &) {
     co_yield 0; // expected-error {{'co_yield' cannot be used in a copy assignment operator}}
   }
----------------
modocache wrote:
> lewissbaker wrote:
> > Not related to this diff, but...
> > 
> > I don't think that these should be ill-formed.
> > 
> > According to N4775 there are only exclusions added for [class.ctor] and [class.dtor].
> > I can't see anything in the spec that says that assignment special member functions cannot be coroutines.
> That's a great point. Could you create a Bugzilla for this work? And maybe we can get @GorNishanov's opinion?
In 2015, such as https://wg21.link/N4499 there was a blank prohibition: 
"A special member function shall not be a coroutine."

Later, at @rsmith suggestion, we relaxed it a little and banned only constructors and destructors.

I am not yet aware of any use cases where such coroutines would be useful.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59076/new/

https://reviews.llvm.org/D59076





More information about the cfe-commits mailing list