diff options
author | Eli Friedman <eli.friedman@gmail.com> | 2009-05-25 19:41:42 +0000 |
---|---|---|
committer | Eli Friedman <eli.friedman@gmail.com> | 2009-05-25 19:41:42 +0000 |
commit | cf7530ff43e5025912f351a2b68e5298558a6d95 (patch) | |
tree | 18a0e6e07361fa8b7fae2952b5807e83e175736d /clang | |
parent | 23464b8f14d4a84fa419423362de2e95e49460b9 (diff) | |
download | bcm5719-llvm-cf7530ff43e5025912f351a2b68e5298558a6d95.tar.gz bcm5719-llvm-cf7530ff43e5025912f351a2b68e5298558a6d95.zip |
PR4122: Tweak the ambiguity handling to handle (S())() correctly. I've
left out handling for stuff like (S())++ for the moment.
llvm-svn: 72394
Diffstat (limited to 'clang')
-rw-r--r-- | clang/lib/Parse/ParseExprCXX.cpp | 17 | ||||
-rw-r--r-- | clang/test/Parser/cxx-ambig-paren-expr.cpp | 7 |
2 files changed, 18 insertions, 6 deletions
diff --git a/clang/lib/Parse/ParseExprCXX.cpp b/clang/lib/Parse/ParseExprCXX.cpp index 5e6ba680679..681c6adb2ea 100644 --- a/clang/lib/Parse/ParseExprCXX.cpp +++ b/clang/lib/Parse/ParseExprCXX.cpp @@ -1088,12 +1088,17 @@ Parser::ParseCXXAmbiguousParenExpression(ParenParseOption &ExprType, ParseAs = CompoundLiteral; } else { bool NotCastExpr; - // Try parsing the cast-expression that may follow. - // If it is not a cast-expression, NotCastExpr will be true and no token - // will be consumed. - Result = ParseCastExpression(false/*isUnaryExpression*/, - false/*isAddressofOperand*/, - NotCastExpr); + // FIXME: Special-case ++ and --: "(S())++;" is not a cast-expression + if (Tok.is(tok::l_paren) && NextToken().is(tok::r_paren)) { + NotCastExpr = true; + } else { + // Try parsing the cast-expression that may follow. + // If it is not a cast-expression, NotCastExpr will be true and no token + // will be consumed. + Result = ParseCastExpression(false/*isUnaryExpression*/, + false/*isAddressofOperand*/, + NotCastExpr); + } // If we parsed a cast-expression, it's really a type-id, otherwise it's // an expression. diff --git a/clang/test/Parser/cxx-ambig-paren-expr.cpp b/clang/test/Parser/cxx-ambig-paren-expr.cpp index 00695612562..6f23b35d3e6 100644 --- a/clang/test/Parser/cxx-ambig-paren-expr.cpp +++ b/clang/test/Parser/cxx-ambig-paren-expr.cpp @@ -16,4 +16,11 @@ void f() { typedef int *PT; // Make sure stuff inside the parens are parsed only once (only one warning). x = (PT()[(int){1}]); // expected-warning {{compound literals}} + + // Special case: empty parens is a call, not an expression + struct S{int operator()();}; + (S())(); + + // FIXME: Special case: "++" is postfix here, not prefix + // (S())++; } |