Allow 'static' and type qualifiers in K&R parameter type lists.

llvm-svn: 161980
This commit is contained in:
Matt Beaumont-Gay 2012-08-15 19:53:19 +00:00
parent 135611f7fc
commit 22be8d5ab8
2 changed files with 6 additions and 1 deletions

View File

@ -2263,7 +2263,8 @@ static TypeSourceInfo *GetFullTypeForDeclarator(TypeProcessingState &state,
// shall appear only in a declaration of a function parameter with an // shall appear only in a declaration of a function parameter with an
// array type, ... // array type, ...
if (ASM == ArrayType::Static || ATI.TypeQuals) { if (ASM == ArrayType::Static || ATI.TypeQuals) {
if (!D.isPrototypeContext()) { if (!(D.isPrototypeContext() ||
D.getContext() == Declarator::KNRTypeListContext)) {
S.Diag(DeclType.Loc, diag::err_array_static_outside_prototype) << S.Diag(DeclType.Loc, diag::err_array_static_outside_prototype) <<
(ASM == ArrayType::Static ? "'static'" : "type qualifier"); (ASM == ArrayType::Static ? "'static'" : "type qualifier");
// Remove the 'static' and the type qualifiers. // Remove the 'static' and the type qualifiers.

View File

@ -51,3 +51,7 @@ void n(int *(x)[static 10]); // no-warning
void o(int (x[static 10])(void)); // expected-error{{'x' declared as array of functions of type 'int (void)'}} void o(int (x[static 10])(void)); // expected-error{{'x' declared as array of functions of type 'int (void)'}}
void p(int (^x)[static 10]); // expected-error{{block pointer to non-function type is invalid}} void p(int (^x)[static 10]); // expected-error{{block pointer to non-function type is invalid}}
void q(int (^x[static 10])()); // no-warning void q(int (^x[static 10])()); // no-warning
void r(x)
int x[restrict]; // no-warning
{}