[cfe-commits] r110445 - in /cfe/trunk: lib/Parse/ParseExpr.cpp test/SemaCXX/inc-decrement-qualifiers.cpp test/SemaCXX/increment-decrement.cpp
Douglas Gregor
dgregor at apple.com
Fri Aug 6 07:50:36 PDT 2010
Author: dgregor
Date: Fri Aug 6 09:50:36 2010
New Revision: 110445
URL: http://llvm.org/viewvc/llvm-project?rev=110445&view=rev
Log:
The pre-increment/pre-decrement grammar in C++ differs from that in C,
but we were parsing the C grammar. Handle the C++ grammar
appropriately. Fixes PR7794.
Added:
cfe/trunk/test/SemaCXX/increment-decrement.cpp
- copied, changed from r110442, cfe/trunk/test/SemaCXX/inc-decrement-qualifiers.cpp
Removed:
cfe/trunk/test/SemaCXX/inc-decrement-qualifiers.cpp
Modified:
cfe/trunk/lib/Parse/ParseExpr.cpp
Modified: cfe/trunk/lib/Parse/ParseExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseExpr.cpp?rev=110445&r1=110444&r2=110445&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseExpr.cpp (original)
+++ cfe/trunk/lib/Parse/ParseExpr.cpp Fri Aug 6 09:50:36 2010
@@ -568,7 +568,7 @@
// If this expression is limited to being a unary-expression, the parent can
// not start a cast expression.
ParenParseOption ParenExprType =
- isUnaryExpression ? CompoundLiteral : CastExpr;
+ (isUnaryExpression && !getLang().CPlusPlus)? CompoundLiteral : CastExpr;
TypeTy *CastTy;
SourceLocation LParenLoc = Tok.getLocation();
SourceLocation RParenLoc;
@@ -702,10 +702,14 @@
case tok::kw___null:
return Actions.ActOnGNUNullExpr(ConsumeToken());
break;
- case tok::plusplus: // unary-expression: '++' unary-expression
- case tok::minusminus: { // unary-expression: '--' unary-expression
+ case tok::plusplus: // unary-expression: '++' unary-expression [C99]
+ case tok::minusminus: { // unary-expression: '--' unary-expression [C99]
+ // C++ [expr.unary] has:
+ // unary-expression:
+ // ++ cast-expression
+ // -- cast-expression
SourceLocation SavedLoc = ConsumeToken();
- Res = ParseCastExpression(true);
+ Res = ParseCastExpression(!getLang().CPlusPlus);
if (!Res.isInvalid())
Res = Actions.ActOnUnaryOp(getCurScope(), SavedLoc, SavedKind, move(Res));
return move(Res);
Removed: cfe/trunk/test/SemaCXX/inc-decrement-qualifiers.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/inc-decrement-qualifiers.cpp?rev=110444&view=auto
==============================================================================
--- cfe/trunk/test/SemaCXX/inc-decrement-qualifiers.cpp (original)
+++ cfe/trunk/test/SemaCXX/inc-decrement-qualifiers.cpp (removed)
@@ -1,9 +0,0 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
-
-volatile int i;
-
-const int &inc = i++;
-const int &dec = i--;
-
-const int &incfail = ++i; // expected-error {{drops qualifiers}}
-const int &decfail = --i; // expected-error {{drops qualifiers}}
Copied: cfe/trunk/test/SemaCXX/increment-decrement.cpp (from r110442, cfe/trunk/test/SemaCXX/inc-decrement-qualifiers.cpp)
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/increment-decrement.cpp?p2=cfe/trunk/test/SemaCXX/increment-decrement.cpp&p1=cfe/trunk/test/SemaCXX/inc-decrement-qualifiers.cpp&r1=110442&r2=110445&rev=110445&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/inc-decrement-qualifiers.cpp (original)
+++ cfe/trunk/test/SemaCXX/increment-decrement.cpp Fri Aug 6 09:50:36 2010
@@ -7,3 +7,8 @@
const int &incfail = ++i; // expected-error {{drops qualifiers}}
const int &decfail = --i; // expected-error {{drops qualifiers}}
+
+// PR7794
+void f0(int e) {
+ ++(int&)e;
+}
More information about the cfe-commits
mailing list