[Heikki Kultala] This patch contains the ABI changes for the TCE target.
[clang.git] / test / Analysis / array-struct-region.c
blob8162200b0aca3e23903f9e1e5af57b5a85a80d1d
1 // RUN: %clang_cc1 -analyze -analyzer-experimental-checks -analyzer-experimental-internal-checks -analyzer-checker=core.experimental.UnreachableCode -analyzer-check-objc-mem -analyzer-store=region -analyzer-constraints=basic -verify %s
2 // RUN: %clang_cc1 -analyze -analyzer-experimental-checks -analyzer-experimental-internal-checks -analyzer-checker=core.experimental.UnreachableCode -analyzer-check-objc-mem -analyzer-store=region -analyzer-constraints=range -verify %s
4 int string_literal_init() {
5 char a[] = "abc";
6 char b[2] = "abc"; // expected-warning{{too long}}
7 char c[5] = "abc";
9 if (a[1] != 'b')
10 return 0; // expected-warning{{never executed}}
11 if (b[1] != 'b')
12 return 0; // expected-warning{{never executed}}
13 if (c[1] != 'b')
14 return 0; // expected-warning{{never executed}}
16 if (a[3] != 0)
17 return 0; // expected-warning{{never executed}}
18 if (c[3] != 0)
19 return 0; // expected-warning{{never executed}}
21 if (c[4] != 0)
22 return 0; // expected-warning{{never executed}}
24 return 42;
27 void nested_compound_literals(int rad) {
28 int vec[6][2] = {{0.195, 0.02}, {0.383, 0.067}, {0.55, 0.169},
29 {0.831, 0.45}, {0.924, 0.617}, {0.98, 0.805}};
30 int a;
32 for (a = 0; a < 6; ++a) {
33 vec[a][0] *= rad; // no-warning
34 vec[a][1] *= rad; // no-warning
38 void nested_compound_literals_float(float rad) {
39 float vec[6][2] = {{0.195, 0.02}, {0.383, 0.067}, {0.55, 0.169},
40 {0.831, 0.45}, {0.924, 0.617}, {0.98, 0.805}};
41 int a;
43 for (a = 0; a < 6; ++a) {
44 vec[a][0] *= rad; // no-warning
45 vec[a][1] *= rad; // no-warning