Debian Codegraph @

clang/test/Analysis/loop-block-counts.c

raw
1 // RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -verify %s
2
3 void clang_analyzer_eval(int);
4
5 void callee(void **p) {
6 int x;
7 *p = &x;
8 // expected-warning@-1 {{Address of stack memory associated with local \
9 variable 'x' is still referred to by the caller variable 'arr' upon \
10 returning to the caller}}
11 }
12
13 void loop(void) {
14 void *arr[2];
15 for (int i = 0; i < 2; ++i)
16 callee(&arr[i]);
17 // FIXME: Should be UNKNOWN.
18 clang_analyzer_eval(arr[0] == arr[1]); // expected-warning{{FALSE}}
19 }
20
21 void loopWithCall(void) {
22 void *arr[2];
23 for (int i = 0; i < 2; ++i) {
24 int x;
25 arr[i] = &x;
26 }
27 // FIXME: Should be UNKNOWN.
28 clang_analyzer_eval(arr[0] == arr[1]); // expected-warning{{TRUE}}
29 }