17f397c5d97fc0c11333d939f2c07bc3b230956e2Hans Wennborg// RUN: %clang_cc1 -fsyntax-only -fblocks -verify %s 220cdbeb8f36576f469db195b4140c293c7281718Peter Collingbourne 320cdbeb8f36576f469db195b4140c293c7281718Peter Collingbournevoid cat0(int a[static 0]) {} // expected-warning {{'static' has no effect on zero-length arrays}} 420cdbeb8f36576f469db195b4140c293c7281718Peter Collingbourne 520cdbeb8f36576f469db195b4140c293c7281718Peter Collingbournevoid cat(int a[static 3]) {} // expected-note 2 {{callee declares array parameter as static here}} 620cdbeb8f36576f469db195b4140c293c7281718Peter Collingbourne 720cdbeb8f36576f469db195b4140c293c7281718Peter Collingbournevoid vat(int i, int a[static i]) {} // expected-note {{callee declares array parameter as static here}} 820cdbeb8f36576f469db195b4140c293c7281718Peter Collingbourne 920cdbeb8f36576f469db195b4140c293c7281718Peter Collingbournevoid f(int *p) { 1020cdbeb8f36576f469db195b4140c293c7281718Peter Collingbourne int a[2], b[3], c[4]; 1120cdbeb8f36576f469db195b4140c293c7281718Peter Collingbourne 1220cdbeb8f36576f469db195b4140c293c7281718Peter Collingbourne cat0(0); 1320cdbeb8f36576f469db195b4140c293c7281718Peter Collingbourne 1420cdbeb8f36576f469db195b4140c293c7281718Peter Collingbourne cat(0); // expected-warning {{null passed to a callee which requires a non-null argument}} 1520cdbeb8f36576f469db195b4140c293c7281718Peter Collingbourne cat(a); // expected-warning {{array argument is too small; contains 2 elements, callee requires at least 3}} 1620cdbeb8f36576f469db195b4140c293c7281718Peter Collingbourne cat(b); 1720cdbeb8f36576f469db195b4140c293c7281718Peter Collingbourne cat(c); 1820cdbeb8f36576f469db195b4140c293c7281718Peter Collingbourne cat(p); 1920cdbeb8f36576f469db195b4140c293c7281718Peter Collingbourne 2020cdbeb8f36576f469db195b4140c293c7281718Peter Collingbourne vat(1, 0); // expected-warning {{null passed to a callee which requires a non-null argument}} 2120cdbeb8f36576f469db195b4140c293c7281718Peter Collingbourne vat(3, b); 2220cdbeb8f36576f469db195b4140c293c7281718Peter Collingbourne} 237f397c5d97fc0c11333d939f2c07bc3b230956e2Hans Wennborg 247f397c5d97fc0c11333d939f2c07bc3b230956e2Hans Wennborg 257f397c5d97fc0c11333d939f2c07bc3b230956e2Hans Wennborgtypedef int td[static 3]; // expected-error {{'static' used in array declarator outside of function prototype}} 267f397c5d97fc0c11333d939f2c07bc3b230956e2Hans Wennborgtypedef void(*fp)(int[static 42]); // no-warning 277f397c5d97fc0c11333d939f2c07bc3b230956e2Hans Wennborg 287f397c5d97fc0c11333d939f2c07bc3b230956e2Hans Wennborgvoid g(void) { 297f397c5d97fc0c11333d939f2c07bc3b230956e2Hans Wennborg int a[static 42]; // expected-error {{'static' used in array declarator outside of function prototype}} 307f397c5d97fc0c11333d939f2c07bc3b230956e2Hans Wennborg 317f397c5d97fc0c11333d939f2c07bc3b230956e2Hans Wennborg int b[const 10]; // expected-error {{type qualifier used in array declarator outside of function prototype}} 327f397c5d97fc0c11333d939f2c07bc3b230956e2Hans Wennborg int c[volatile 10]; // expected-error {{type qualifier used in array declarator outside of function prototype}} 337f397c5d97fc0c11333d939f2c07bc3b230956e2Hans Wennborg int d[restrict 10]; // expected-error {{type qualifier used in array declarator outside of function prototype}} 347f397c5d97fc0c11333d939f2c07bc3b230956e2Hans Wennborg 357f397c5d97fc0c11333d939f2c07bc3b230956e2Hans Wennborg int e[static restrict 1]; // expected-error {{'static' used in array declarator outside of function prototype}} 367f397c5d97fc0c11333d939f2c07bc3b230956e2Hans Wennborg} 377f397c5d97fc0c11333d939f2c07bc3b230956e2Hans Wennborg 387f397c5d97fc0c11333d939f2c07bc3b230956e2Hans Wennborgvoid h(int [static const 10][42]); // no-warning 397f397c5d97fc0c11333d939f2c07bc3b230956e2Hans Wennborg 407f397c5d97fc0c11333d939f2c07bc3b230956e2Hans Wennborgvoid i(int [10] 417f397c5d97fc0c11333d939f2c07bc3b230956e2Hans Wennborg [static 42]); // expected-error {{'static' used in non-outermost array type derivation}} 427f397c5d97fc0c11333d939f2c07bc3b230956e2Hans Wennborg 437f397c5d97fc0c11333d939f2c07bc3b230956e2Hans Wennborgvoid j(int [10] 447f397c5d97fc0c11333d939f2c07bc3b230956e2Hans Wennborg [const 42]); // expected-error {{type qualifier used in non-outermost array type derivation}} 457f397c5d97fc0c11333d939f2c07bc3b230956e2Hans Wennborg 467f397c5d97fc0c11333d939f2c07bc3b230956e2Hans Wennborgvoid k(int (*x)[static 10]); // expected-error {{'static' used in non-outermost array type derivation}} 477f397c5d97fc0c11333d939f2c07bc3b230956e2Hans Wennborgvoid l(int (x)[static 10]); // no-warning 487f397c5d97fc0c11333d939f2c07bc3b230956e2Hans Wennborgvoid m(int *x[static 10]); // no-warning 497f397c5d97fc0c11333d939f2c07bc3b230956e2Hans Wennborgvoid n(int *(x)[static 10]); // no-warning 507f397c5d97fc0c11333d939f2c07bc3b230956e2Hans Wennborg 517f397c5d97fc0c11333d939f2c07bc3b230956e2Hans Wennborgvoid o(int (x[static 10])(void)); // expected-error{{'x' declared as array of functions of type 'int (void)'}} 527f397c5d97fc0c11333d939f2c07bc3b230956e2Hans Wennborgvoid p(int (^x)[static 10]); // expected-error{{block pointer to non-function type is invalid}} 537f397c5d97fc0c11333d939f2c07bc3b230956e2Hans Wennborgvoid q(int (^x[static 10])()); // no-warning 5499570a58b09fca5d0b328733ab8b6717a1a04f4aMatt Beaumont-Gay 5599570a58b09fca5d0b328733ab8b6717a1a04f4aMatt Beaumont-Gayvoid r(x) 5699570a58b09fca5d0b328733ab8b6717a1a04f4aMatt Beaumont-Gay int x[restrict]; // no-warning 5799570a58b09fca5d0b328733ab8b6717a1a04f4aMatt Beaumont-Gay{} 58