Hans Wennborg | 7f397c5 | 2012-08-15 07:42:30 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fsyntax-only -fblocks -verify %s |
Peter Collingbourne | 20cdbeb | 2011-10-16 21:17:32 +0000 | [diff] [blame] | 2 | |
| 3 | void cat0(int a[static 0]) {} // expected-warning {{'static' has no effect on zero-length arrays}} |
| 4 | |
| 5 | void cat(int a[static 3]) {} // expected-note 2 {{callee declares array parameter as static here}} |
| 6 | |
Peter Collingbourne | 20cdbeb | 2011-10-16 21:17:32 +0000 | [diff] [blame] | 7 | void vat(int i, int a[static i]) {} // expected-note {{callee declares array parameter as static here}} |
| 8 | |
| 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 which 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 | |
Peter Collingbourne | 20cdbeb | 2011-10-16 21:17:32 +0000 | [diff] [blame] | 20 | vat(1, 0); // expected-warning {{null passed to a callee which requires a non-null argument}} |
| 21 | vat(3, b); |
| 22 | } |
Hans Wennborg | 7f397c5 | 2012-08-15 07:42:30 +0000 | [diff] [blame] | 23 | |
| 24 | |
| 25 | typedef int td[static 3]; // expected-error {{'static' used in array declarator outside of function prototype}} |
| 26 | typedef void(*fp)(int[static 42]); // no-warning |
| 27 | |
| 28 | void g(void) { |
| 29 | int a[static 42]; // expected-error {{'static' used in array declarator outside of function prototype}} |
| 30 | |
| 31 | int b[const 10]; // expected-error {{type qualifier used in array declarator outside of function prototype}} |
| 32 | int c[volatile 10]; // expected-error {{type qualifier used in array declarator outside of function prototype}} |
| 33 | int d[restrict 10]; // expected-error {{type qualifier used in array declarator outside of function prototype}} |
| 34 | |
| 35 | int e[static restrict 1]; // expected-error {{'static' used in array declarator outside of function prototype}} |
| 36 | } |
| 37 | |
| 38 | void h(int [static const 10][42]); // no-warning |
| 39 | |
| 40 | void i(int [10] |
| 41 | [static 42]); // expected-error {{'static' used in non-outermost array type derivation}} |
| 42 | |
| 43 | void j(int [10] |
| 44 | [const 42]); // expected-error {{type qualifier used in non-outermost array type derivation}} |
| 45 | |
| 46 | void k(int (*x)[static 10]); // expected-error {{'static' used in non-outermost array type derivation}} |
| 47 | void l(int (x)[static 10]); // no-warning |
| 48 | void m(int *x[static 10]); // no-warning |
| 49 | void n(int *(x)[static 10]); // no-warning |
| 50 | |
| 51 | void o(int (x[static 10])(void)); // expected-error{{'x' declared as array of functions of type 'int (void)'}} |
| 52 | void p(int (^x)[static 10]); // expected-error{{block pointer to non-function type is invalid}} |
| 53 | void q(int (^x[static 10])()); // no-warning |
Matt Beaumont-Gay | 99570a5 | 2012-08-15 19:53:19 +0000 | [diff] [blame] | 54 | |
| 55 | void r(x) |
| 56 | int x[restrict]; // no-warning |
| 57 | {} |