Remove ParseSimpleParenExpression.
Embed its functionality into it's only user, ParseCXXCasts.
CXXCasts now get the "actual" expression directly, they no longer always receive a ParenExpr. This is better since the
parentheses are always part of the C++ casts syntax.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72257 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/include/clang/Parse/Parser.h b/include/clang/Parse/Parser.h
index bc5a3a5..69488fc 100644
--- a/include/clang/Parse/Parser.h
+++ b/include/clang/Parse/Parser.h
@@ -688,16 +688,6 @@
OwningExprResult ParseParenExpression(ParenParseOption &ExprType,
TypeTy *&CastTy,
SourceLocation &RParenLoc);
-
- OwningExprResult ParseSimpleParenExpression() { // Parse SimpleExpr only.
- SourceLocation RParenLoc;
- return ParseSimpleParenExpression(RParenLoc);
- }
- OwningExprResult ParseSimpleParenExpression(SourceLocation &RParenLoc) {
- ParenParseOption Op = SimpleExpr;
- TypeTy *CastTy;
- return ParseParenExpression(Op, CastTy, RParenLoc);
- }
OwningExprResult ParseStringLiteralExpression();
diff --git a/lib/Parse/ParseExprCXX.cpp b/lib/Parse/ParseExprCXX.cpp
index c065b47..f2a5902 100644
--- a/lib/Parse/ParseExprCXX.cpp
+++ b/lib/Parse/ParseExprCXX.cpp
@@ -322,10 +322,19 @@
SourceLocation LParenLoc = Tok.getLocation(), RParenLoc;
- if (Tok.isNot(tok::l_paren))
- return ExprError(Diag(Tok, diag::err_expected_lparen_after) << CastName);
+ if (ExpectAndConsume(tok::l_paren, diag::err_expected_lparen_after, CastName))
+ return ExprError();
- OwningExprResult Result(ParseSimpleParenExpression(RParenLoc));
+ OwningExprResult Result = ParseExpression();
+
+ // Match the ')'.
+ if (Result.isInvalid())
+ SkipUntil(tok::r_paren);
+
+ if (Tok.is(tok::r_paren))
+ RParenLoc = ConsumeParen();
+ else
+ MatchRHSPunctuation(tok::r_paren, LParenLoc);
if (!Result.isInvalid() && !CastTy.isInvalid())
Result = Actions.ActOnCXXNamedCast(OpLoc, Kind,