forked from OSchip/llvm-project
Factor the compound literal parsing out from ParseParenExpression and into a new ParseCompoundLiteralExpression.
No functionality change. llvm-svn: 72259
This commit is contained in:
parent
9a9c0f4eff
commit
5da1f08587
|
@ -690,6 +690,10 @@ private:
|
||||||
TypeTy *&CastTy,
|
TypeTy *&CastTy,
|
||||||
SourceLocation &RParenLoc);
|
SourceLocation &RParenLoc);
|
||||||
|
|
||||||
|
OwningExprResult ParseCompoundLiteralExpression(TypeTy *Ty,
|
||||||
|
SourceLocation LParenLoc,
|
||||||
|
SourceLocation RParenLoc);
|
||||||
|
|
||||||
OwningExprResult ParseStringLiteralExpression();
|
OwningExprResult ParseStringLiteralExpression();
|
||||||
|
|
||||||
//===--------------------------------------------------------------------===//
|
//===--------------------------------------------------------------------===//
|
||||||
|
|
|
@ -1239,14 +1239,8 @@ Parser::ParseParenExpression(ParenParseOption &ExprType, bool stopIfCastExpr,
|
||||||
MatchRHSPunctuation(tok::r_paren, OpenLoc);
|
MatchRHSPunctuation(tok::r_paren, OpenLoc);
|
||||||
|
|
||||||
if (Tok.is(tok::l_brace)) {
|
if (Tok.is(tok::l_brace)) {
|
||||||
if (!getLang().C99) // Compound literals don't exist in C90.
|
|
||||||
Diag(OpenLoc, diag::ext_c99_compound_literal);
|
|
||||||
Result = ParseInitializer();
|
|
||||||
ExprType = CompoundLiteral;
|
ExprType = CompoundLiteral;
|
||||||
if (!Result.isInvalid() && !Ty.isInvalid())
|
return ParseCompoundLiteralExpression(Ty.get(), OpenLoc, RParenLoc);
|
||||||
Result = Actions.ActOnCompoundLiteral(OpenLoc, Ty.get(), RParenLoc,
|
|
||||||
move(Result));
|
|
||||||
return move(Result);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ExprType == CastExpr) {
|
if (ExprType == CastExpr) {
|
||||||
|
@ -1294,6 +1288,26 @@ Parser::ParseParenExpression(ParenParseOption &ExprType, bool stopIfCastExpr,
|
||||||
return move(Result);
|
return move(Result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// ParseCompoundLiteralExpression - We have parsed the parenthesized type-name
|
||||||
|
/// and we are at the left brace.
|
||||||
|
///
|
||||||
|
/// postfix-expression: [C99 6.5.2]
|
||||||
|
/// '(' type-name ')' '{' initializer-list '}'
|
||||||
|
/// '(' type-name ')' '{' initializer-list ',' '}'
|
||||||
|
///
|
||||||
|
Parser::OwningExprResult
|
||||||
|
Parser::ParseCompoundLiteralExpression(TypeTy *Ty,
|
||||||
|
SourceLocation LParenLoc,
|
||||||
|
SourceLocation RParenLoc) {
|
||||||
|
assert(Tok.is(tok::l_brace) && "Not a compound literal!");
|
||||||
|
if (!getLang().C99) // Compound literals don't exist in C90.
|
||||||
|
Diag(LParenLoc, diag::ext_c99_compound_literal);
|
||||||
|
OwningExprResult Result = ParseInitializer();
|
||||||
|
if (!Result.isInvalid() && Ty)
|
||||||
|
return Actions.ActOnCompoundLiteral(LParenLoc, Ty, RParenLoc, move(Result));
|
||||||
|
return move(Result);
|
||||||
|
}
|
||||||
|
|
||||||
/// ParseStringLiteralExpression - This handles the various token types that
|
/// ParseStringLiteralExpression - This handles the various token types that
|
||||||
/// form string literals, and also handles string concatenation [C99 5.1.1.2,
|
/// form string literals, and also handles string concatenation [C99 5.1.1.2,
|
||||||
/// translation phase #6].
|
/// translation phase #6].
|
||||||
|
|
Loading…
Reference in New Issue