Mercurial > hg > CbC > CbC_gcc
view 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 |
line wrap: on
line source
// PR c++/56135 // { dg-do run { target c++11 } } #include <functional> struct test { template<typename T> std::function<void()> broken(int x) { return [=] { +x; print<T>(); }; // { dg-warning "implicit capture" "" { target c++2a } } } std::function<void()> works0() { return [=] { print<int>(); }; // { dg-warning "implicit capture" "" { target c++2a } } } template<typename T> std::function<void()> works1() { return [=] { print<int>(); }; // { dg-warning "implicit capture" "" { target c++2a } } } template<typename T> std::function<void()> works2() { return [=] { this->print<T>(); }; // { dg-warning "implicit capture" "" { target c++2a } } } template<typename T> void print() { if (this == 0) __builtin_abort (); } }; int main(void) { test().broken<int>(1)(); test().works0()(); test().works1<int>()(); test().works2<int>()(); return 0; }