summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-deduce-ext-neg.C
blob: bfe7acab69bced42b4947f631c0c658c05cf0bd1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// Testcase for an extension to allow return type deduction when the lambda
// contains more than just a single return-statement.

// { dg-options -std=c++0x }

bool b;
template <class T>
T f (T t)
{
  return [=]
    {
      auto i = t+1;
      if (b)
	return i+1;
      else
	return i+2;		// { dg-error "lambda return type" }
    }();
}

int main()
{
  if (f(1) != 3)
    return 1;
}