• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // RUN: %clang_cc1 -verify -Warray-bounds-pointer-arithmetic %s
2 
3 // Test case from PR10615
4 struct ext2_super_block{
5   unsigned char s_uuid[8]; // expected-note {{declared here}}
6 };
ext2_statfs(struct ext2_super_block * es,int a)7 void* ext2_statfs (struct ext2_super_block *es,int a)
8 {
9 	 return (void *)es->s_uuid + sizeof(int); // no-warning
10 }
broken(struct ext2_super_block * es,int a)11 void* broken (struct ext2_super_block *es,int a)
12 {
13 	 return (void *)es->s_uuid + 80; // expected-warning {{refers past the end of the array}}
14 }
15 
16 // Test case reduced from PR11594
17 struct S { int n; };
pr11594(struct S * s)18 void pr11594(struct S *s) {
19   int a[10];
20   int *p = a - s->n;
21 }
22