aboutsummaryrefslogtreecommitdiff
path: root/clang/test/SemaObjC/flexible-array-bounds.m
blob: 1da535c8487ac742c2eae9dca821e4acf6285c0c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
// RUN: %clang_cc1 -fsyntax-only -verify %s
// expected-no-diagnostics
//
// RUN: %clang_cc1 -fsyntax-only -fstrict-flex-arrays=2 -verify=warn %s

@interface Flexible {
@public
  char flexible[];
}
@end

@interface Flexible0 {
@public
  char flexible[0];
}
@end

@interface Flexible1 {
@public
  char flexible[1];
}
@end

char readit(Flexible *p) { return p->flexible[2]; }
char readit0(Flexible0 *p) { return p->flexible[2]; }
char readit1(Flexible1 *p) { return p->flexible[2]; } // warn-warning {{array index 2 is past the end of the array (that has type 'char[1]')}}