1 // RUN: %clang_cc1 -triple x86_64-apple-macosx10.14.0 -fsyntax-only -fblocks -pedantic -verify %s
2 
cat0(int a[static0])3 void cat0(int a[static 0]) {} // expected-warning {{zero size arrays are an extension}} \
4                               // expected-note {{callee declares array parameter as static here}}
5 
cat(int a[static3])6 void cat(int a[static 3]) {} // expected-note 4 {{callee declares array parameter as static here}} expected-note 2 {{passing argument to parameter 'a' here}}
7 
vat(int i,int a[static i])8 void vat(int i, int a[static i]) {} // expected-note {{callee declares array parameter as static here}}
9 
f(int * p)10 void f(int *p) {
11   int a[2], b[3], c[4];
12 
13   cat0(0); // expected-warning {{null passed to a callee that requires a non-null argument}}
14 
15   cat(0); // expected-warning {{null passed to a callee that requires a non-null argument}}
16   cat(a); // expected-warning {{array argument is too small; contains 2 elements, callee requires at least 3}}
17   cat(b);
18   cat(c);
19   cat(p);
20 
21   vat(1, 0); // expected-warning {{null passed to a callee that requires a non-null argument}}
22   vat(3, b);
23 
24   char d[4];
25   cat((int *)d); // expected-warning {{array argument is too small; is of size 4, callee requires at least 12}}
26   cat(d); // expected-warning {{array argument is too small; is of size 4, callee requires at least 12}} expected-warning {{incompatible pointer types}}
27 
28   char e[12];
29   cat((int *)e);
30   cat(e); // expected-warning {{incompatible pointer types}}
31 }
32 
33 
34 typedef int td[static 3]; // expected-error {{'static' used in array declarator outside of function prototype}}
35 typedef void(*fp)(int[static 42]); // no-warning
36 
g(void)37 void g(void) {
38   int a[static 42]; // expected-error {{'static' used in array declarator outside of function prototype}}
39 
40   int b[const 10]; // expected-error {{type qualifier used in array declarator outside of function prototype}}
41   int c[volatile 10]; // expected-error {{type qualifier used in array declarator outside of function prototype}}
42   int d[restrict 10]; // expected-error {{type qualifier used in array declarator outside of function prototype}}
43 
44   int e[static restrict 1]; // expected-error {{'static' used in array declarator outside of function prototype}}
45 }
46 
47 void h(int [static const 10][42]); // no-warning
48 
49 void i(int [10]
50        [static 42]); // expected-error {{'static' used in non-outermost array type derivation}}
51 
52 void j(int [10]
53        [const 42]); // expected-error {{type qualifier used in non-outermost array type derivation}}
54 
55 void k(int (*x)[static 10]); // expected-error {{'static' used in non-outermost array type derivation}}
56 void l(int (x)[static 10]); // no-warning
57 void m(int *x[static 10]); // no-warning
58 void n(int *(x)[static 10]); // no-warning
59 
60 void o(int (x[static 10])(void)); // expected-error{{'x' declared as array of functions of type 'int (void)'}}
61 void p(int (^x)[static 10]); // expected-error{{block pointer to non-function type is invalid}}
62 void q(int (^x[static 10])()); // no-warning
63 
r(x)64 void r(x)
65   int x[restrict]; // no-warning
66 {}
67