Allow 'static' and type qualifiers in K&R parameter type lists.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@161980 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaType.cpp b/lib/Sema/SemaType.cpp
index 7b7cc99..54f8dba 100644
--- a/lib/Sema/SemaType.cpp
+++ b/lib/Sema/SemaType.cpp
@@ -2263,7 +2263,8 @@
// 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/test/Sema/static-array.c b/test/Sema/static-array.c
index be8957c..5ca693b 100644
--- a/test/Sema/static-array.c
+++ b/test/Sema/static-array.c
@@ -51,3 +51,7 @@
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
+{}