1 // RUN: %clang_cc1 -fsyntax-only -std=c++11 %s -verify 2 3 // Check that analysis-based warnings work in lambda bodies. analysis_based_warnings()4void analysis_based_warnings() { 5 (void)[]() -> int { }; // expected-warning{{control reaches end of non-void lambda}} 6 } 7 8 // Check that we get the right types of captured variables (the 9 // semantic-analysis part of p7). 10 int &check_const_int(int&); 11 float &check_const_int(const int&); 12 test_capture_constness(int i,const int ic)13void test_capture_constness(int i, const int ic) { 14 (void)[i,ic] ()->void { 15 float &fr1 = check_const_int(i); 16 float &fr2 = check_const_int(ic); 17 }; 18 19 (void)[=] ()->void { 20 float &fr1 = check_const_int(i); 21 float &fr2 = check_const_int(ic); 22 }; 23 24 (void)[i,ic] () mutable ->void { 25 int &ir = check_const_int(i); 26 float &fr = check_const_int(ic); 27 }; 28 29 (void)[=] () mutable ->void { 30 int &ir = check_const_int(i); 31 float &fr = check_const_int(ic); 32 }; 33 34 (void)[&i,&ic] ()->void { 35 int &ir = check_const_int(i); 36 float &fr = check_const_int(ic); 37 }; 38 39 (void)[&] ()->void { 40 int &ir = check_const_int(i); 41 float &fr = check_const_int(ic); 42 }; 43 } 44 45 46 struct S1 { 47 int x, y; 48 S1 &operator=(int*); 49 int operator()(int); fS150 void f() { 51 [&]()->int { 52 S1 &s1 = operator=(&this->x); 53 return operator()(this->x + y); 54 }(); 55 } 56 }; 57