YouCompleteMe/cpp/llvm/tools/clang/test/Sema/array-bounds-ptr-arith.c
Strahinja Val Markovic 1f51a89d39 Adding more llvm/clang files
These were ignored by git accidentally. We want ALL OF THEM since they all came
in the llvm/clang source distribution.
2012-07-05 17:55:45 -07:00

22 lines
560 B
C

// 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}}
}
// Test case reduced from PR11594
struct S { int n; };
void pr11594(struct S *s) {
int a[10];
int *p = a - s->n;
}