From 90efe0bfd6bf9887747c7b4c82b7917c0b066c78 Mon Sep 17 00:00:00 2001 From: Richard Smith <richard-llvm@metafoo.co.uk> Date: Wed, 3 Feb 2016 18:48:43 +0000 Subject: [PATCH] Fix regression from r259622: the operand of an increment that is the operand of a cast expression is not the operand of a cast expression itself, so if it's parenthesized we need to form a ParenExpr not a ParenListExpr. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@259677 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Parse/ParseExpr.cpp | 4 ++-- test/Parser/cxx-ambig-paren-expr.cpp | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/Parse/ParseExpr.cpp b/lib/Parse/ParseExpr.cpp index f76e2297337..8a6bcb3b37b 100644 --- a/lib/Parse/ParseExpr.cpp +++ b/lib/Parse/ParseExpr.cpp @@ -516,7 +516,7 @@ class CastExpressionIdValidator : public CorrectionCandidateCallback { /// \p isAddressOfOperand exists because an id-expression that is the operand /// of address-of gets special treatment due to member pointers. NotCastExpr /// is set to true if the token is not the start of a cast-expression, and no -/// diagnostic is emitted in this case. +/// diagnostic is emitted in this case and no tokens are consumed. /// /// \verbatim /// cast-expression: [C99 6.5.4] @@ -1020,7 +1020,7 @@ ExprResult Parser::ParseCastExpression(bool isUnaryExpression, // determine whether the '++' is prefix or postfix. Res = ParseCastExpression(!getLangOpts().CPlusPlus, /*isAddressOfOperand*/false, NotCastExpr, - isTypeCast); + NotTypeCast); if (NotCastExpr) { // If we return with NotCastExpr = true, we must not consume any tokens, // so put the token back where we found it. diff --git a/test/Parser/cxx-ambig-paren-expr.cpp b/test/Parser/cxx-ambig-paren-expr.cpp index 1535b009725..cc509f7b059 100644 --- a/test/Parser/cxx-ambig-paren-expr.cpp +++ b/test/Parser/cxx-ambig-paren-expr.cpp @@ -28,6 +28,7 @@ void f() { int &postfix_incr = (X()[3])++; (X())++ ++; // ok, not a C-style cast (X())++ ++X(); // expected-error {{C-style cast from 'int' to 'X ()'}} + int q = (int)++(x); } // Make sure we do tentative parsing correctly in conditions. -- GitLab