From 0fb0bb179a162ee4e1971e8349fafd9c3daae2ac Mon Sep 17 00:00:00 2001 From: Kaelyn Uhrain Date: Wed, 10 Aug 2011 19:47:25 +0000 Subject: Add a test case for the divide-by-zero fix in r137234 llvm-svn: 137240 --- clang/test/Sema/array-bounds-ptr-arith.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 clang/test/Sema/array-bounds-ptr-arith.c (limited to 'clang/test/Sema/array-bounds-ptr-arith.c') diff --git a/clang/test/Sema/array-bounds-ptr-arith.c b/clang/test/Sema/array-bounds-ptr-arith.c new file mode 100644 index 00000000000..c0e0d0ea785 --- /dev/null +++ b/clang/test/Sema/array-bounds-ptr-arith.c @@ -0,0 +1,14 @@ +// RUN: %clang_cc1 -verify -Warray-bounds-pointer-arithmetic %s + +// Test case from PR10615 +struct ext2_super_block{ + unsigned char s_uuid[8]; // expected-note {{declared here}} +}; +void* ext2_statfs (struct ext2_super_block *es,int a) +{ + return (void *)es->s_uuid + sizeof(int); // no-warning +} +void* broken (struct ext2_super_block *es,int a) +{ + return (void *)es->s_uuid + 80; // expected-warning {{refers past the end of the array}} +} -- cgit v1.2.3