]> granicus.if.org Git - clang/commitdiff
[coroutines] Support braced-init-list as operand of co_yield expression.
authorRichard Smith <richard-llvm@metafoo.co.uk>
Fri, 20 Nov 2015 22:47:10 +0000 (22:47 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Fri, 20 Nov 2015 22:47:10 +0000 (22:47 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@253726 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Parse/ParseExprCXX.cpp
test/SemaCXX/coroutines.cpp

index 477594b5a162551e107f814266a06e9b7cf4670b..f8938ba3495b36c29f1479f7eeba14ecd61874c4 100644 (file)
@@ -1568,7 +1568,8 @@ ExprResult Parser::ParseCoyieldExpression() {
   assert(Tok.is(tok::kw_co_yield) && "Not co_yield!");
 
   SourceLocation Loc = ConsumeToken();
-  ExprResult Expr = ParseAssignmentExpression();
+  ExprResult Expr = Tok.is(tok::l_brace) ? ParseBraceInitializer()
+                                         : ParseAssignmentExpression();
   if (!Expr.isInvalid())
     Expr = Actions.ActOnCoyieldExpr(getCurScope(), Loc, Expr.get());
   return Expr;
index 9e15217031e11489e76f01a5425797116f4e35fc..15536d83074040696101bf345e83745f68140c0f 100644 (file)
@@ -44,7 +44,7 @@ void undefined_promise() { // expected-error {{variable has incomplete type 'pro
   co_await a;
 }
 
-struct yielded_thing { int a, b, c; const char *p; };
+struct yielded_thing { const char *p; short a, b; };
 
 struct promise {
   awaitable yield_value(int); // expected-note {{candidate}}
@@ -53,7 +53,10 @@ struct promise {
 
 void yield() {
   co_yield 0;
-  co_yield {1, 2, 3, "foo"}; // FIXME expected-error {{expected expression}}
+  co_yield {"foo", 1, 2};
+  co_yield {1e100}; // expected-error {{cannot be narrowed}} expected-note {{explicit cast}} expected-warning {{changes value}} expected-warning {{braces around scalar}}
+  co_yield {"foo", __LONG_LONG_MAX__}; // expected-error {{cannot be narrowed}} expected-note {{explicit cast}} expected-warning {{changes value}}
+  co_yield {"foo"};
   co_yield "foo"; // expected-error {{no matching}}
 }