stack-addr-ps.cpp revision 8b2f01b56209f4bb7331292225c5300753880044
1// RUN: %clang_cc1 -fsyntax-only -fblocks -verify %s
2
3// FIXME: Only the stack-address checking in Sema catches this right now, and
4// the stack analyzer doesn't handle the ImplicitCastExpr (lvalue).
5const int& g() {
6  int s;
7  return s; // expected-warning{{reference to stack memory associated with local variable 's' returned}}
8}
9
10int get_value();
11
12const int &get_reference1() { return get_value(); } // expected-warning {{returning reference to local temporary}}
13
14const int &get_reference2() {
15  int const& w2 = get_value(); // expected-note {{binding variable 'w2' to temporary here}}
16  return w2; // expected-warning {{reference to temporary associated with local variable 'w2' returned}}
17}
18