Enforce C99 6.7.5.3p3, rejecting code like:

void foo(void (*q)(a,b,c)) {}

llvm-svn: 39240
This commit is contained in:
Chris Lattner 2006-12-03 07:14:39 +00:00
parent 969ca15b41
commit 0d89d5a638
2 changed files with 10 additions and 0 deletions

View File

@ -133,6 +133,11 @@ TypeRef Sema::GetTypeForDeclarator(Declarator &D, Scope *S) {
if (!FTI.hasPrototype) {
// Simple void foo(), where the incoming T is the result type.
T = Context.getFunctionTypeNoProto(T);
// C99 6.7.5.3p3: Reject int(x,y,z) when it's not a function definition.
if (FTI.NumArgs != 0)
Diag(FTI.ArgInfo[0].IdentLoc, diag::err_ident_list_in_fn_declaration);
} else {
// Otherwise, we have a function with an argument list that is
// potentially variadic.

View File

@ -133,6 +133,11 @@ TypeRef Sema::GetTypeForDeclarator(Declarator &D, Scope *S) {
if (!FTI.hasPrototype) {
// Simple void foo(), where the incoming T is the result type.
T = Context.getFunctionTypeNoProto(T);
// C99 6.7.5.3p3: Reject int(x,y,z) when it's not a function definition.
if (FTI.NumArgs != 0)
Diag(FTI.ArgInfo[0].IdentLoc, diag::err_ident_list_in_fn_declaration);
} else {
// Otherwise, we have a function with an argument list that is
// potentially variadic.