summaryrefslogtreecommitdiffstats
path: root/clang/test/Sema/offsetof-64.c
diff options
context:
space:
mode:
authorRichard Trieu <rtrieu@google.com>2013-05-16 01:46:09 +0000
committerRichard Trieu <rtrieu@google.com>2013-05-16 01:46:09 +0000
commit388a33f3a317706eef720374be388b84154dedd7 (patch)
treef9dd6c3a113443150131ca2a6a4f06521608d300 /clang/test/Sema/offsetof-64.c
parentf37f51f0cb0be9163cf765547b60bd6747ea8eaa (diff)
downloadbcm5719-llvm-388a33f3a317706eef720374be388b84154dedd7.tar.gz
bcm5719-llvm-388a33f3a317706eef720374be388b84154dedd7.zip
Return QualType() when a too large array is attempting to be created. This
prevents further errors and some overflows in size calculations. One overflow was previously triggering an assert. llvm-svn: 181970
Diffstat (limited to 'clang/test/Sema/offsetof-64.c')
-rw-r--r--clang/test/Sema/offsetof-64.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/clang/test/Sema/offsetof-64.c b/clang/test/Sema/offsetof-64.c
index 1cabec9842f..fb3d6e98d1c 100644
--- a/clang/test/Sema/offsetof-64.c
+++ b/clang/test/Sema/offsetof-64.c
@@ -1,15 +1,22 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s -triple x86_64-linux-gnu
-// expected-no-diagnostics
// PR15216
// Don't crash when taking computing the offset of structs with large arrays.
const unsigned long Size = (1l << 62);
-struct Chunk {
+struct Chunk1 {
char padding[Size];
char more_padding[1][Size];
char data;
};
-int test1 = __builtin_offsetof(struct Chunk, data);
+int test1 = __builtin_offsetof(struct Chunk1, data);
+struct Chunk2 {
+ char padding[Size][Size][Size]; // expected-error 2{{array is too large}}
+ char data;
+};
+
+// FIXME: Remove this error when the constant evaluator learns to
+// ignore bad types.
+int test2 = __builtin_offsetof(struct Chunk2, data); // expected-error{{initializer element is not a compile-time constant}}
OpenPOWER on IntegriCloud