summaryrefslogtreecommitdiffstats
path: root/clang/test/Sema/array-size.c
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2010-08-18 00:39:00 +0000
committerDouglas Gregor <dgregor@apple.com>2010-08-18 00:39:00 +0000
commitcaa1bf434d93a9cd583e05c8247649276ad3eeba (patch)
tree7dbbef626f45c1123abe1a38dd8022c57ef6246e /clang/test/Sema/array-size.c
parentb91c903f461b2d92675aca44481742df0b6daca7 (diff)
downloadbcm5719-llvm-caa1bf434d93a9cd583e05c8247649276ad3eeba.tar.gz
bcm5719-llvm-caa1bf434d93a9cd583e05c8247649276ad3eeba.zip
Emit an error if an array is too large. We're slightly more strict
than GCC 4.2 here when building 32-bit (where GCC will allow allocation of an array for which we can't get a valid past-the-end pointer), and emulate its odd behavior in 64-bit where it only allows 63 bits worth of storage in the array. The former is a correctness issue; the latter is harmless in practice (you wouldn't be able to use such an array anyway) and helps us pass a GCC DejaGNU test. Fixes <rdar://problem/8212293>. llvm-svn: 111338
Diffstat (limited to 'clang/test/Sema/array-size.c')
-rw-r--r--clang/test/Sema/array-size.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/clang/test/Sema/array-size.c b/clang/test/Sema/array-size.c
new file mode 100644
index 00000000000..7580e3ecc51
--- /dev/null
+++ b/clang/test/Sema/array-size.c
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -triple i686-apple-darwin -verify %s
+
+void f() {
+ int x0[1073741824]; // expected-error{{array is too large}}
+ int x1[1073741824 + 1]; // expected-error{{array is too large}}
+ int x2[(unsigned)1073741824]; // expected-error{{array is too large}}
+ int x3[(unsigned)1073741824 + 1]; // expected-error{{array is too large}}
+ int x4[1073741824 - 1];
+}
+
OpenPOWER on IntegriCloud