improve and simplify error recovery for calls, fix a crash when diagnosing
invalid arguments.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40161 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/Sema/SemaType.cpp b/Sema/SemaType.cpp
index 5b1db6e..c2777fd 100644
--- a/Sema/SemaType.cpp
+++ b/Sema/SemaType.cpp
@@ -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);