summaryrefslogtreecommitdiffstats
path: root/clang/test/Analysis/stackaddrleak.c
blob: b9088fa81b9b1ab473e1bac7dd1a90542336903d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
// RUN: %clang_cc1 -analyze -analyzer-check-objc-mem -analyzer-store region -analyzer-experimental-internal-checks -verify %s

char const *p;

void f0() {
  char const str[] = "This will change";
  p = str; // expected-warning {{Stack address was saved into a global variable.}}
}

void f1() {
  char const str[] = "This will change";
  p = str; 
  p = 0; // no-warning
}

void f2() {
  p = (const char *) __builtin_alloca(12); // expected-warning {{Stack address was saved into a global variable.}}
}
OpenPOWER on IntegriCloud