1// RUN: %clang_cc1 -x objective-c -emit-llvm -triple x86_64-apple-macosx10.10.0 -Wno-objc-root-class -fsanitize=array-bounds %s -o - | FileCheck %s
2
3@interface FlexibleArray1 {
4@public
5  char chars[0];
6}
7@end
8@implementation FlexibleArray1
9@end
10
11// CHECK-LABEL: test_FlexibleArray1
12char test_FlexibleArray1(FlexibleArray1 *FA1) {
13  // CHECK-NOT: !nosanitize
14  return FA1->chars[1];
15  // CHECK: }
16}
17
18@interface FlexibleArray2 {
19@public
20  char chars[0];
21}
22@end
23@implementation FlexibleArray2 {
24@public
25  char chars2[0];
26}
27@end
28
29// CHECK-LABEL: test_FlexibleArray2_1
30char test_FlexibleArray2_1(FlexibleArray2 *FA2) {
31  // CHECK: !nosanitize
32  return FA2->chars[1];
33  // CHECK: }
34}
35
36// CHECK-LABEL: test_FlexibleArray2_2
37char test_FlexibleArray2_2(FlexibleArray2 *FA2) {
38  // CHECK-NOT: !nosanitize
39  return FA2->chars2[1];
40  // CHECK: }
41}
42
43@interface FlexibleArray3 {
44@public
45  char chars[0];
46}
47@end
48@implementation FlexibleArray3 {
49@public
50  int i;
51}
52@end
53
54// CHECK-LABEL: test_FlexibleArray3
55char test_FlexibleArray3(FlexibleArray3 *FA3) {
56  // CHECK: !nosanitize
57  return FA3->chars[1];
58  // CHECK: }
59}
60