blob: 847ed7da5b17f49eca723d98dfcdf1137de8b54f [file] [log] [blame]
Zhongxing Xu9b146832010-06-09 06:08:24 +00001// RUN: %clang_cc1 -analyze -analyzer-check-objc-mem -analyzer-store region -verify %s
Zhongxing Xu1622a542010-06-08 10:00:00 +00002
3char const *p;
4
5void f0() {
6 char const str[] = "This will change";
7 p = str; // expected-warning {{Stack address was saved into a global variable.}}
8}
9
10void f1() {
11 char const str[] = "This will change";
12 p = str;
13 p = 0; // no-warning
14}
Zhongxing Xu2c464582010-06-09 05:50:38 +000015
16void f2() {
17 p = (const char *) __builtin_alloca(12); // expected-warning {{Stack address was saved into a global variable.}}
18}
Ted Kremenek551bd1f2010-06-17 00:24:44 +000019
20// PR 7383 - previosly the stack address checker would crash on this example
21// because it would attempt to do a direct load from 'pr7383_list'.
22static int pr7383(__const char *__)
23{
24 return 0;
25}
26extern __const char *__const pr7383_list[];