aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/g++.dg/warn/Wreturn-local-addr.C
blob: faa3a345440c8e939218591087a9f0e3ca9dc3ee (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// { dg-do assemble  }
// { dg-options "-Werror=return-local-addr" }
// { dg-message "some warnings being treated as errors" "" {target "*-*-*"} 0 }

int& bad1()
{
  int x = 0;		// { dg-error "reference to local variable" }
  return x;
}

int* bad2()
{
  int x = 0;		// { dg-error "address of local variable" }
  return &x;
}

const int& bad4()
{
  return int();		// { dg-error "returning reference to temporary" }
}