diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp index 7b7cc99dffb9..54f8dbaf0127 100644 --- a/clang/lib/Sema/SemaType.cpp +++ b/clang/lib/Sema/SemaType.cpp @@ -2263,7 +2263,8 @@ static TypeSourceInfo *GetFullTypeForDeclarator(TypeProcessingState &state, // shall appear only in a declaration of a function parameter with an // array type, ... 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) << (ASM == ArrayType::Static ? "'static'" : "type qualifier"); // Remove the 'static' and the type qualifiers. diff --git a/clang/test/Sema/static-array.c b/clang/test/Sema/static-array.c index be8957c254f4..5ca693b2bf54 100644 --- a/clang/test/Sema/static-array.c +++ b/clang/test/Sema/static-array.c @@ -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 p(int (^x)[static 10]); // expected-error{{block pointer to non-function type is invalid}} void q(int (^x[static 10])()); // no-warning + +void r(x) + int x[restrict]; // no-warning +{}