mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2024-12-12 09:41:26 +00:00
Fix parsing of fold-expressions within a cast expression. We parse the
parenthesized expression a bit differently in this case, just in case the commas have special meaning. llvm-svn: 221661
This commit is contained in:
parent
a0d5643610
commit
ea97e36dfc
@ -2203,24 +2203,30 @@ Parser::ParseParenExpression(ParenParseOption &ExprType, bool stopIfCastExpr,
|
||||
Diag(Tok, diag::err_expected_lbrace_in_compound_literal);
|
||||
return ExprError();
|
||||
}
|
||||
} else if (Tok.is(tok::ellipsis) &&
|
||||
isFoldOperator(NextToken().getKind())) {
|
||||
return ParseFoldExpression(ExprResult(), T);
|
||||
} else if (isTypeCast) {
|
||||
// Parse the expression-list.
|
||||
InMessageExpressionRAIIObject InMessage(*this, false);
|
||||
|
||||
|
||||
ExprVector ArgExprs;
|
||||
CommaLocsTy CommaLocs;
|
||||
|
||||
if (!ParseSimpleExpressionList(ArgExprs, CommaLocs)) {
|
||||
// FIXME: If we ever support comma expressions as operands to
|
||||
// fold-expressions, we'll need to allow multiple ArgExprs here.
|
||||
if (ArgExprs.size() == 1 && isFoldOperator(Tok.getKind()) &&
|
||||
NextToken().is(tok::ellipsis))
|
||||
return ParseFoldExpression(Result, T);
|
||||
|
||||
ExprType = SimpleExpr;
|
||||
Result = Actions.ActOnParenListExpr(OpenLoc, Tok.getLocation(),
|
||||
ArgExprs);
|
||||
}
|
||||
} else if (Tok.is(tok::ellipsis) &&
|
||||
isFoldOperator(NextToken().getKind())) {
|
||||
return ParseFoldExpression(ExprResult(), T);
|
||||
} else {
|
||||
InMessageExpressionRAIIObject InMessage(*this, false);
|
||||
|
||||
|
||||
Result = ParseExpression(MaybeTypeCast);
|
||||
ExprType = SimpleExpr;
|
||||
|
||||
|
@ -55,10 +55,9 @@ template<int ...N> void empty_with_base() {
|
||||
extern int k;
|
||||
(k = ... = N); // expected-warning{{unused}}
|
||||
|
||||
// FIXME: We misparse these. The first one looks a lot loke a declaration;
|
||||
// it's not clear what's happening in the second one.
|
||||
void (k = ... = N); // expected-error {{expected ')'}} expected-note {{to match}}
|
||||
(void) (k = ... = N); // expected-error {{expected ')'}} expected-note {{to match}}
|
||||
void ((k = ... = N));
|
||||
(void) (k = ... = N);
|
||||
}
|
||||
template void empty_with_base<>(); // expected-note {{in instantiation of}}
|
||||
template void empty_with_base<1>();
|
||||
|
Loading…
Reference in New Issue
Block a user