aboutsummaryrefslogtreecommitdiff
path: root/test/Analysis/stack-addr-ps.c
blob: c59df0904dd517512ba998a886f3251a1682a1cb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// RUN: clang -checker-simple -verify %s

int* f1() {
  int x = 0;
  return &x; // expected-warning{{Address of stack-allocated variable returned.}} expected-warning{{address of stack memory associated with local variable 'x' returned}}
}

int* f2(int y) {
  return &y;  // expected-warning{{Address of stack-allocated variable returned.}} expected-warning{{address of stack memory associated with local variable 'y' returned}}
}

int* f3(int x, int *y) {
  int w = 0;
  
  if (x)
    y = &w;
    
  return y; // expected-warning{{Address of stack-allocated variable returned.}}
}