annotate gcc/testsuite/g++.dg/cpp0x/lambda/lambda-this8.C @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents 04ced10e8804
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 // PR c++/56135
kono
parents:
diff changeset
2 // { dg-do run { target c++11 } }
kono
parents:
diff changeset
3
kono
parents:
diff changeset
4 #include <functional>
kono
parents:
diff changeset
5
kono
parents:
diff changeset
6 struct test {
kono
parents:
diff changeset
7 template<typename T>
kono
parents:
diff changeset
8 std::function<void()> broken(int x) {
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
9 return [=] { +x; print<T>(); }; // { dg-warning "implicit capture" "" { target c++2a } }
111
kono
parents:
diff changeset
10 }
kono
parents:
diff changeset
11
kono
parents:
diff changeset
12 std::function<void()> works0() {
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
13 return [=] { print<int>(); }; // { dg-warning "implicit capture" "" { target c++2a } }
111
kono
parents:
diff changeset
14 }
kono
parents:
diff changeset
15
kono
parents:
diff changeset
16 template<typename T>
kono
parents:
diff changeset
17 std::function<void()> works1() {
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
18 return [=] { print<int>(); }; // { dg-warning "implicit capture" "" { target c++2a } }
111
kono
parents:
diff changeset
19 }
kono
parents:
diff changeset
20
kono
parents:
diff changeset
21 template<typename T>
kono
parents:
diff changeset
22 std::function<void()> works2() {
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
23 return [=] { this->print<T>(); }; // { dg-warning "implicit capture" "" { target c++2a } }
111
kono
parents:
diff changeset
24 }
kono
parents:
diff changeset
25
kono
parents:
diff changeset
26 template<typename T>
kono
parents:
diff changeset
27 void print() { if (this == 0) __builtin_abort (); }
kono
parents:
diff changeset
28 };
kono
parents:
diff changeset
29
kono
parents:
diff changeset
30 int main(void) {
kono
parents:
diff changeset
31 test().broken<int>(1)();
kono
parents:
diff changeset
32 test().works0()();
kono
parents:
diff changeset
33 test().works1<int>()();
kono
parents:
diff changeset
34 test().works2<int>()();
kono
parents:
diff changeset
35
kono
parents:
diff changeset
36 return 0;
kono
parents:
diff changeset
37 }