annotate clang/test/Analysis/outofbound-notwork.c @ 236:c4bab56944e8 llvm-original

LLVM 16
author kono
date Wed, 09 Nov 2022 17:45:10 +0900
parents 1d019706d866
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
236
c4bab56944e8 LLVM 16
kono
parents: 150
diff changeset
1 // RUN: %clang_analyze_cc1 -Wno-array-bounds -analyzer-checker=core,alpha.security.ArrayBound -verify %s
150
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 }