summaryrefslogtreecommitdiffstats
path: root/clang/lib/Parse/ParseExpr.cpp
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2016-02-03 02:58:20 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2016-02-03 02:58:20 +0000
commit4378568c8f4203966f42f0705040845179708a0f (patch)
tree1212cc59ca35acfed01e9cb6f06bb8c09262925d /clang/lib/Parse/ParseExpr.cpp
parent9f7ec14009d8a45058409044fcf7f3d4f924f75c (diff)
downloadbcm5719-llvm-4378568c8f4203966f42f0705040845179708a0f.tar.gz
bcm5719-llvm-4378568c8f4203966f42f0705040845179708a0f.zip
Fix miscompile and rejects-valids when disambiguating after an ambiguous
C-style-cast to function/array type or parenthesized function-style cast/array indexing. llvm-svn: 259622
Diffstat (limited to 'clang/lib/Parse/ParseExpr.cpp')
-rw-r--r--clang/lib/Parse/ParseExpr.cpp15
1 files changed, 12 insertions, 3 deletions
diff --git a/clang/lib/Parse/ParseExpr.cpp b/clang/lib/Parse/ParseExpr.cpp
index ad23804d1da..13b77223acc 100644
--- a/clang/lib/Parse/ParseExpr.cpp
+++ b/clang/lib/Parse/ParseExpr.cpp
@@ -1010,15 +1010,24 @@ ExprResult Parser::ParseCastExpression(bool isUnaryExpression,
// unary-expression:
// ++ cast-expression
// -- cast-expression
- SourceLocation SavedLoc = ConsumeToken();
+ Token SavedTok = Tok;
+ ConsumeToken();
// One special case is implicitly handled here: if the preceding tokens are
// an ambiguous cast expression, such as "(T())++", then we recurse to
// determine whether the '++' is prefix or postfix.
Res = ParseCastExpression(!getLangOpts().CPlusPlus,
/*isAddressOfOperand*/false, NotCastExpr,
- NotTypeCast);
+ isTypeCast);
+ if (NotCastExpr) {
+ // If we return with NotCastExpr = true, we must not consume any tokens,
+ // so put the token back where we found it.
+ assert(Res.isInvalid());
+ UnconsumeToken(SavedTok);
+ return ExprError();
+ }
if (!Res.isInvalid())
- Res = Actions.ActOnUnaryOp(getCurScope(), SavedLoc, SavedKind, Res.get());
+ Res = Actions.ActOnUnaryOp(getCurScope(), SavedTok.getLocation(),
+ SavedKind, Res.get());
return Res;
}
case tok::amp: { // unary-expression: '&' cast-expression
OpenPOWER on IntegriCloud