r259677 - Fix regression from r259622: the operand of an increment that is the operand of

Richard Smith via cfe-commits cfe-commits at lists.llvm.org
Wed Feb 3 10:48:43 PST 2016


Author: rsmith
Date: Wed Feb  3 12:48:43 2016
New Revision: 259677

URL: http://llvm.org/viewvc/llvm-project?rev=259677&view=rev
Log:
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.

Modified:
    cfe/trunk/lib/Parse/ParseExpr.cpp
    cfe/trunk/test/Parser/cxx-ambig-paren-expr.cpp

Modified: cfe/trunk/lib/Parse/ParseExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseExpr.cpp?rev=259677&r1=259676&r2=259677&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseExpr.cpp (original)
+++ cfe/trunk/lib/Parse/ParseExpr.cpp Wed Feb  3 12:48:43 2016
@@ -516,7 +516,7 @@ class CastExpressionIdValidator : public
 /// \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(b
     // 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.

Modified: cfe/trunk/test/Parser/cxx-ambig-paren-expr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/cxx-ambig-paren-expr.cpp?rev=259677&r1=259676&r2=259677&view=diff
==============================================================================
--- cfe/trunk/test/Parser/cxx-ambig-paren-expr.cpp (original)
+++ cfe/trunk/test/Parser/cxx-ambig-paren-expr.cpp Wed Feb  3 12:48:43 2016
@@ -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.




More information about the cfe-commits mailing list