summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--clang/lib/Parse/ParseExprCXX.cpp3
-rw-r--r--clang/test/SemaCXX/coroutines.cpp7
2 files changed, 7 insertions, 3 deletions
diff --git a/clang/lib/Parse/ParseExprCXX.cpp b/clang/lib/Parse/ParseExprCXX.cpp
index 477594b5a16..f8938ba3495 100644
--- a/clang/lib/Parse/ParseExprCXX.cpp
+++ b/clang/lib/Parse/ParseExprCXX.cpp
@@ -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;
diff --git a/clang/test/SemaCXX/coroutines.cpp b/clang/test/SemaCXX/coroutines.cpp
index 9e15217031e..15536d83074 100644
--- a/clang/test/SemaCXX/coroutines.cpp
+++ b/clang/test/SemaCXX/coroutines.cpp
@@ -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}}
}
OpenPOWER on IntegriCloud