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