Debian Codegraph @

gcc/testsuite/g++.dg/cpp0x/lambda/lambda-deduce-ext-neg.C

raw
1 // Testcase for DR 975.
2
3 // { dg-do compile { target c++11 } }
4
5 bool b;
6 struct A { int fn1(); const int& fn2(); };
7 struct B { int fn1(); long fn2(); };
8
9 template <class T> int f (T t) {
10 return [](T t){
11 if (b)
12 return t.fn1();
13 else
14 return t.fn2(); // { dg-error "19:inconsistent types" }
15 }(t);
16 }
17
18 int main()
19 {
20 f(A()); // { dg-bogus "" } int and const int& are compatible
21 f(B()); // { dg-message "from here" } int and long are not
22 }