diff options
Diffstat (limited to 'test/CodeGen/bounds-checking.c')
-rw-r--r-- | test/CodeGen/bounds-checking.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/test/CodeGen/bounds-checking.c b/test/CodeGen/bounds-checking.c new file mode 100644 index 0000000..e278620 --- /dev/null +++ b/test/CodeGen/bounds-checking.c @@ -0,0 +1,26 @@ +// RUN: %clang_cc1 -fbounds-checking=4 -emit-llvm -triple x86_64-apple-darwin10 < %s | FileCheck %s + +// CHECK: @f +double f(int b, int i) { + double a[b]; + // CHECK: trap + return a[i]; +} + +// CHECK: @f2 +void f2() { + // everything is constant; no trap possible + // CHECK-NOT: trap + int a[2]; + a[1] = 42; + + short *b = malloc(64); + b[5] = *a + a[1] + 2; +} + +// CHECK: @f3 +void f3() { + int a[1]; + // CHECK: trap + a[2] = 1; +} |