[cfe-commits] r40161 - in /cfe/trunk: Parse/ParseExpr.cpp Sema/SemaType.cpp
Chris Lattner
sabre at nondot.org
Fri Jul 20 22:18:13 PDT 2007
Author: lattner
Date: Sat Jul 21 00:18:12 2007
New Revision: 40161
URL: http://llvm.org/viewvc/llvm-project?rev=40161&view=rev
Log:
improve and simplify error recovery for calls, fix a crash when diagnosing
invalid arguments.
Modified:
cfe/trunk/Parse/ParseExpr.cpp
cfe/trunk/Sema/SemaType.cpp
Modified: cfe/trunk/Parse/ParseExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Parse/ParseExpr.cpp?rev=40161&r1=40160&r2=40161&view=diff
==============================================================================
--- cfe/trunk/Parse/ParseExpr.cpp (original)
+++ cfe/trunk/Parse/ParseExpr.cpp Sat Jul 21 00:18:12 2007
@@ -624,7 +624,6 @@
case tok::l_paren: { // p-e: p-e '(' argument-expression-list[opt] ')'
llvm::SmallVector<ExprTy*, 8> ArgExprs;
llvm::SmallVector<SourceLocation, 8> CommaLocs;
- bool ArgExprsOk = true;
Loc = ConsumeParen();
@@ -632,9 +631,8 @@
while (1) {
ExprResult ArgExpr = ParseAssignmentExpression();
if (ArgExpr.isInvalid) {
- ArgExprsOk = false;
SkipUntil(tok::r_paren);
- break;
+ return ExprResult(true);
} else
ArgExprs.push_back(ArgExpr.Val);
@@ -646,15 +644,14 @@
}
// Match the ')'.
- if (!LHS.isInvalid && ArgExprsOk && Tok.getKind() == tok::r_paren) {
+ if (!LHS.isInvalid && Tok.getKind() == tok::r_paren) {
assert((ArgExprs.size() == 0 || ArgExprs.size()-1 == CommaLocs.size())&&
"Unexpected number of commas!");
LHS = Actions.ParseCallExpr(LHS.Val, Loc, &ArgExprs[0], ArgExprs.size(),
&CommaLocs[0], Tok.getLocation());
}
- if (ArgExprsOk)
- MatchRHSPunctuation(tok::r_paren, Loc);
+ MatchRHSPunctuation(tok::r_paren, Loc);
break;
}
case tok::arrow: // postfix-expression: p-e '->' identifier
Modified: cfe/trunk/Sema/SemaType.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Sema/SemaType.cpp?rev=40161&r1=40160&r2=40161&view=diff
==============================================================================
--- cfe/trunk/Sema/SemaType.cpp (original)
+++ cfe/trunk/Sema/SemaType.cpp Sat Jul 21 00:18:12 2007
@@ -204,19 +204,20 @@
// have arguments of incomplete type.
if (FTI.NumArgs != 1 || FTI.isVariadic) {
Diag(DeclType.Loc, diag::err_void_only_param);
- return QualType();
- }
- // Reject, but continue to parse 'int(void abc)'.
- if (FTI.ArgInfo[i].Ident)
+ ArgTy = Context.IntTy;
+ } else if (FTI.ArgInfo[i].Ident) {
+ // Reject, but continue to parse 'int(void abc)'.
Diag(FTI.ArgInfo[i].IdentLoc,
diag::err_void_param_with_identifier);
-
- // Reject, but continue to parse 'float(const void)'.
- if (ArgTy.getQualifiers())
- Diag(DeclType.Loc, diag::err_void_param_qualified);
-
- // Do not add 'void' to the ArgTys list.
- break;
+ ArgTy = Context.IntTy;
+ } else {
+ // Reject, but continue to parse 'float(const void)'.
+ if (ArgTy.getQualifiers())
+ Diag(DeclType.Loc, diag::err_void_param_qualified);
+
+ // Do not add 'void' to the ArgTys list.
+ break;
+ }
}
ArgTys.push_back(ArgTy);
More information about the cfe-commits
mailing list