annotate clang/test/Analysis/outofbound-notwork.c @ 222:81f6424ef0e3 llvm-original

LLVM original branch
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Sun, 18 Jul 2021 22:10:01 +0900
parents 1d019706d866
children c4bab56944e8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
150
anatofuz
parents:
diff changeset
1 // RUN: %clang_analyze_cc1 -Wno-array-bounds -analyzer-checker=core,alpha.security.ArrayBound -analyzer-store=region -verify %s
anatofuz
parents:
diff changeset
2 // XFAIL: *
anatofuz
parents:
diff changeset
3
anatofuz
parents:
diff changeset
4 // Once we better handle modeling of sizes of VLAs, we can pull this back
anatofuz
parents:
diff changeset
5 // into outofbound.c.
anatofuz
parents:
diff changeset
6
anatofuz
parents:
diff changeset
7 void sizeof_vla(int a) {
anatofuz
parents:
diff changeset
8 if (a == 5) {
anatofuz
parents:
diff changeset
9 char x[a];
anatofuz
parents:
diff changeset
10 int y[sizeof(x)];
anatofuz
parents:
diff changeset
11 y[4] = 4; // no-warning
anatofuz
parents:
diff changeset
12 y[5] = 5; // expected-warning{{out-of-bound}}
anatofuz
parents:
diff changeset
13 }
anatofuz
parents:
diff changeset
14 }
anatofuz
parents:
diff changeset
15
anatofuz
parents:
diff changeset
16 void sizeof_vla_2(int a) {
anatofuz
parents:
diff changeset
17 if (a == 5) {
anatofuz
parents:
diff changeset
18 char x[a];
anatofuz
parents:
diff changeset
19 int y[sizeof(x) / sizeof(char)];
anatofuz
parents:
diff changeset
20 y[4] = 4; // no-warning
anatofuz
parents:
diff changeset
21 y[5] = 5; // expected-warning{{out-of-bound}}
anatofuz
parents:
diff changeset
22 }
anatofuz
parents:
diff changeset
23 }
anatofuz
parents:
diff changeset
24
anatofuz
parents:
diff changeset
25 void sizeof_vla_3(int a) {
anatofuz
parents:
diff changeset
26 if (a == 5) {
anatofuz
parents:
diff changeset
27 char x[a];
anatofuz
parents:
diff changeset
28 int y[sizeof(*&*&*&x)];
anatofuz
parents:
diff changeset
29 y[4] = 4; // no-warning
anatofuz
parents:
diff changeset
30 y[5] = 5; // expected-warning{{out-of-bound}}
anatofuz
parents:
diff changeset
31 }
anatofuz
parents:
diff changeset
32 }