diff options
author | Chris Lattner <sabre@nondot.org> | 2008-02-10 23:08:00 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2008-02-10 23:08:00 +0000 |
commit | 99d724f6a31b5521ded95adf10ef7f3c62a0b18e (patch) | |
tree | 89fbe3eb38f9fd83dbc7eee9be99e887b6190deb /Parse/ParseDecl.cpp | |
parent | a541d53589f4fe681a136ce6b470d598b6d51ccd (diff) |
Fix PR1999, by emitting a hard error only if an argument declarator is completely
missing. Otherwise, it is an implicit int case, which is valid in c90 and invalid
elsewhere, but accepted as an extension.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@46938 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'Parse/ParseDecl.cpp')
-rw-r--r-- | Parse/ParseDecl.cpp | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/Parse/ParseDecl.cpp b/Parse/ParseDecl.cpp index 368887298e..d6b92119c7 100644 --- a/Parse/ParseDecl.cpp +++ b/Parse/ParseDecl.cpp @@ -1362,6 +1362,8 @@ void Parser::ParseParenDeclarator(Declarator &D) { break; } + SourceLocation DSStart = Tok.getLocation(); + // Parse the declaration-specifiers. DeclSpec DS; ParseDeclarationSpecifiers(DS); @@ -1406,16 +1408,19 @@ void Parser::ParseParenDeclarator(Declarator &D) { // If no parameter was specified, verify that *something* was specified, // otherwise we have a missing type and identifier. - if (!DS.hasTypeSpecifier()) { + if (DS.getParsedSpecifiers() == DeclSpec::PQ_None && + ParmDecl.getIdentifier() == 0 && ParmDecl.getNumTypeObjects() == 0) { + Diag(DSStart, diag::err_missing_param); + } else if (!DS.hasTypeSpecifier() && + (getLang().C99 || getLang().CPlusPlus)) { + // Otherwise, if something was specified but a type specifier wasn't, + // (e.g. "x" or "restrict x" or "restrict"), this is a use of implicit + // int. This is valid in C90, but not in C99 or C++. if (ParmII) Diag(ParmDecl.getIdentifierLoc(), - diag::err_param_requires_type_specifier, ParmII->getName()); + diag::ext_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); + Diag(DSStart, diag::ext_anon_param_requires_type_specifier); } ParamInfo.push_back(DeclaratorChunk::ParamInfo(ParmII, |