Fix PR1965: missing diagnostics for parameters that are missing
type specifiers. This required updating some (buggy) tests, and the
testcase was previously accidentally committed.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@46603 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/Parse/ParseDecl.cpp b/Parse/ParseDecl.cpp
index 003554f..91e77b9 100644
--- a/Parse/ParseDecl.cpp
+++ b/Parse/ParseDecl.cpp
@@ -1350,6 +1350,20 @@
ParmII->getName());
ParmII = 0;
}
+
+ // If no parameter was specified, verify that *something* was specified,
+ // otherwise we have a missing type and identifier.
+ if (!DS.hasTypeSpecifier()) {
+ if (ParmII)
+ Diag(ParmDecl.getIdentifierLoc(),
+ diag::err_param_requires_type_specifier, ParmII->getName());
+ else
+ Diag(Tok.getLocation(), diag::err_anon_param_requires_type_specifier);
+
+ // Default the parameter to 'int'.
+ const char *PrevSpec = 0;
+ DS.SetTypeSpecType(DeclSpec::TST_int, Tok.getLocation(), PrevSpec);
+ }
ParamInfo.push_back(DeclaratorChunk::ParamInfo(ParmII,
ParmDecl.getIdentifierLoc(), ParamTy.Val, ParmDecl.getInvalidType(),