forked from OSchip/llvm-project
PR19751: (T())++ is not a cast-expression.
llvm-svn: 213022
This commit is contained in:
parent
ee54aaef0c
commit
5a477c5e37
|
@ -863,7 +863,12 @@ ExprResult Parser::ParseCastExpression(bool isUnaryExpression,
|
|||
// ++ cast-expression
|
||||
// -- cast-expression
|
||||
SourceLocation SavedLoc = ConsumeToken();
|
||||
Res = ParseCastExpression(!getLangOpts().CPlusPlus);
|
||||
// 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);
|
||||
if (!Res.isInvalid())
|
||||
Res = Actions.ActOnUnaryOp(getCurScope(), SavedLoc, SavedKind, Res.get());
|
||||
return Res;
|
||||
|
|
|
@ -2952,7 +2952,6 @@ Parser::ParseCXXAmbiguousParenExpression(ParenParseOption &ExprType,
|
|||
ParseAs = CompoundLiteral;
|
||||
} else {
|
||||
bool 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 {
|
||||
|
|
|
@ -101,5 +101,11 @@ void PR19748() {
|
|||
(true ? (B(*)())f : p)();
|
||||
}
|
||||
|
||||
void PR19751(int n) {
|
||||
struct T { void operator++(int); };
|
||||
(T())++; // ok, not an ill-formed cast to function type
|
||||
(T())++n; // expected-error {{C-style cast from 'int' to 'T ()' is not allowed}}
|
||||
}
|
||||
|
||||
// PR13619. Must be at end of file.
|
||||
int n = reinterpret_cast // expected-error {{expected '<'}} expected-error {{expected ';'}}
|
||||
|
|
Loading…
Reference in New Issue