diff options
author | Peter Collingbourne <peter@pcc.me.uk> | 2011-10-16 21:17:32 +0000 |
---|---|---|
committer | Peter Collingbourne <peter@pcc.me.uk> | 2011-10-16 21:17:32 +0000 |
commit | 20cdbeb8f36576f469db195b4140c293c7281718 (patch) | |
tree | 4940c014e1bc5193314681d604f8e5cb48eeec7d /test | |
parent | 5405b817e2e56b8d37faee7ddfe4c05c16339562 (diff) |
Add sema checks for calls to functions taking static array parameters
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@142157 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test')
-rw-r--r-- | test/Sema/static-array.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/test/Sema/static-array.c b/test/Sema/static-array.c new file mode 100644 index 0000000000..2d4b968dec --- /dev/null +++ b/test/Sema/static-array.c @@ -0,0 +1,31 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +void cat0(int a[static 0]) {} // expected-warning {{'static' has no effect on zero-length arrays}} + +void cat(int a[static 3]) {} // expected-note 2 {{callee declares array parameter as static here}} + +typedef int i3[static 3]; +void tcat(i3 a) {} + +void vat(int i, int a[static i]) {} // expected-note {{callee declares array parameter as static here}} + +void f(int *p) { + int a[2], b[3], c[4]; + + cat0(0); + + cat(0); // expected-warning {{null passed to a callee which requires a non-null argument}} + cat(a); // expected-warning {{array argument is too small; contains 2 elements, callee requires at least 3}} + cat(b); + cat(c); + cat(p); + + tcat(0); // expected-warning {{null passed to a callee which requires a non-null argument}} + tcat(a); // expected-warning {{array argument is too small; contains 2 elements, callee requires at least 3}} + tcat(b); + tcat(c); + tcat(p); + + vat(1, 0); // expected-warning {{null passed to a callee which requires a non-null argument}} + vat(3, b); +} |