forked from OSchip/llvm-project
[coroutines] Add overloaded unary 'operator co_await'.
llvm-svn: 250991
This commit is contained in:
parent
0f723bb90b
commit
9be594e36d
|
@ -101,6 +101,7 @@ OVERLOADED_OPERATOR_MULTI(Subscript , "[]" , false, t
|
|||
// ?: can *not* be overloaded, but we need the overload
|
||||
// resolution machinery for it.
|
||||
OVERLOADED_OPERATOR_MULTI(Conditional , "?" , false, true , false)
|
||||
OVERLOADED_OPERATOR(Coawait , "co_await", kw_co_await , true , false, false)
|
||||
|
||||
#undef OVERLOADED_OPERATOR_MULTI
|
||||
#undef OVERLOADED_OPERATOR
|
||||
|
|
|
@ -1753,6 +1753,9 @@ CXXNameMangler::mangleOperatorName(OverloadedOperatorKind OO, unsigned Arity) {
|
|||
// The conditional operator can't be overloaded, but we still handle it when
|
||||
// mangling expressions.
|
||||
case OO_Conditional: Out << "qu"; break;
|
||||
// Proposal on cxx-abi-dev, 2015-10-21.
|
||||
// ::= aw # co_await
|
||||
case OO_Coawait: Out << "aw"; break;
|
||||
|
||||
case OO_None:
|
||||
case NUM_OVERLOADED_OPERATORS:
|
||||
|
|
|
@ -1046,6 +1046,14 @@ void MicrosoftCXXNameMangler::mangleOperatorName(OverloadedOperatorKind OO,
|
|||
break;
|
||||
}
|
||||
|
||||
case OO_Coawait: {
|
||||
DiagnosticsEngine &Diags = Context.getDiags();
|
||||
unsigned DiagID = Diags.getCustomDiagID(DiagnosticsEngine::Error,
|
||||
"cannot mangle this operator co_await yet");
|
||||
Diags.Report(Loc, DiagID);
|
||||
break;
|
||||
}
|
||||
|
||||
case OO_None:
|
||||
case NUM_OVERLOADED_OPERATORS:
|
||||
llvm_unreachable("Not an overloaded operator");
|
||||
|
|
|
@ -854,6 +854,7 @@ static Stmt::StmtClass DecodeOperatorCall(const CXXOperatorCallExpr *S,
|
|||
case OO_Arrow:
|
||||
case OO_Call:
|
||||
case OO_Conditional:
|
||||
case OO_Coawait:
|
||||
case NUM_OVERLOADED_OPERATORS:
|
||||
llvm_unreachable("Invalid operator call kind");
|
||||
|
||||
|
|
|
@ -6385,6 +6385,7 @@ OMPClause *Sema::ActOnOpenMPReductionClause(
|
|||
case OO_Call:
|
||||
case OO_Subscript:
|
||||
case OO_Conditional:
|
||||
case OO_Coawait:
|
||||
case NUM_OVERLOADED_OPERATORS:
|
||||
llvm_unreachable("Unexpected reduction identifier");
|
||||
case OO_None:
|
||||
|
|
|
@ -8228,6 +8228,7 @@ void Sema::AddBuiltinOperatorCandidates(OverloadedOperatorKind Op,
|
|||
case OO_Array_New:
|
||||
case OO_Array_Delete:
|
||||
case OO_Call:
|
||||
case OO_Coawait:
|
||||
llvm_unreachable(
|
||||
"Special operators don't use AddBuiltinOperatorCandidates");
|
||||
|
||||
|
|
|
@ -19,3 +19,17 @@ U f(T t) {
|
|||
else
|
||||
co_return {t};
|
||||
}
|
||||
|
||||
struct Y {};
|
||||
struct X { Y operator co_await(); };
|
||||
struct Z {};
|
||||
Y operator co_await(Z);
|
||||
|
||||
void f(X x, Z z) {
|
||||
x.operator co_await();
|
||||
operator co_await(z);
|
||||
}
|
||||
|
||||
void operator co_await(); // expected-error {{must have at least one parameter}}
|
||||
void operator co_await(X, Y, Z); // expected-error {{must be a unary operator}}
|
||||
void operator co_await(int); // expected-error {{parameter of class or enumeration type}}
|
||||
|
|
Loading…
Reference in New Issue