OSDN Git Service

merge in cxx0x-lambdas-branch@152308
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / g++.dg / cpp0x / lambda / lambda-deduce-ext.C
1 // Testcase for an extension to allow return type deduction when the lambda
2 // contains more than just a single return-statement.
3
4 // { dg-options -std=c++0x }
5 // { dg-do run }
6
7 bool b;
8 template <class T>
9 T f (T t)
10 {
11   return [=] {
12     auto i = t+1;
13     if (b)
14       return i+1;
15     else
16       return i+1;
17   }();
18 }
19
20 int main()
21 {
22   // Pointless, but well-formed.
23   [] { return 1; return 2; }();
24
25   if (f(1) != 3)
26     return 1;
27 }