121f4692cSDouglas Gregor // RUN: %clang_cc1 -fsyntax-only -std=c++11 %s -verify
221f4692cSDouglas Gregor 
321f4692cSDouglas Gregor // Check that analysis-based warnings work in lambda bodies.
analysis_based_warnings()421f4692cSDouglas Gregor void analysis_based_warnings() {
5*1da13237SDávid Bolvanský   (void)[]() -> int { }; // expected-warning{{non-void lambda does not return a value}}
621f4692cSDouglas Gregor }
721f4692cSDouglas Gregor 
88390afdeSDouglas Gregor // Check that we get the right types of captured variables (the
98390afdeSDouglas Gregor // semantic-analysis part of p7).
10c70fe353SDouglas Gregor int &check_const_int(int&);
11c70fe353SDouglas Gregor float &check_const_int(const int&);
12c70fe353SDouglas Gregor 
test_capture_constness(int i,const int ic)13c70fe353SDouglas Gregor void test_capture_constness(int i, const int ic) {
14656bc62aSDouglas Gregor   (void)[i,ic] ()->void {
15c70fe353SDouglas Gregor     float &fr1 = check_const_int(i);
16c70fe353SDouglas Gregor     float &fr2 = check_const_int(ic);
17c70fe353SDouglas Gregor   };
18c70fe353SDouglas Gregor 
19656bc62aSDouglas Gregor   (void)[=] ()->void {
20c70fe353SDouglas Gregor     float &fr1 = check_const_int(i);
21c70fe353SDouglas Gregor     float &fr2 = check_const_int(ic);
22c70fe353SDouglas Gregor   };
23c70fe353SDouglas Gregor 
24656bc62aSDouglas Gregor   (void)[i,ic] () mutable ->void {
25c70fe353SDouglas Gregor     int &ir = check_const_int(i);
26c70fe353SDouglas Gregor     float &fr = check_const_int(ic);
27c70fe353SDouglas Gregor   };
28c70fe353SDouglas Gregor 
29656bc62aSDouglas Gregor   (void)[=] () mutable ->void {
30c70fe353SDouglas Gregor     int &ir = check_const_int(i);
31c70fe353SDouglas Gregor     float &fr = check_const_int(ic);
32c70fe353SDouglas Gregor   };
33c70fe353SDouglas Gregor 
34656bc62aSDouglas Gregor   (void)[&i,&ic] ()->void {
35c70fe353SDouglas Gregor     int &ir = check_const_int(i);
36c70fe353SDouglas Gregor     float &fr = check_const_int(ic);
37c70fe353SDouglas Gregor   };
38c70fe353SDouglas Gregor 
39656bc62aSDouglas Gregor   (void)[&] ()->void {
40c70fe353SDouglas Gregor     int &ir = check_const_int(i);
41c70fe353SDouglas Gregor     float &fr = check_const_int(ic);
42c70fe353SDouglas Gregor   };
43c70fe353SDouglas Gregor }
4421f4692cSDouglas Gregor 
4521f4692cSDouglas Gregor 
4604bbab58SDouglas Gregor struct S1 {
4704bbab58SDouglas Gregor   int x, y;
481a22d288SDouglas Gregor   S1 &operator=(int*);
4904bbab58SDouglas Gregor   int operator()(int);
fS15004bbab58SDouglas Gregor   void f() {
5104bbab58SDouglas Gregor     [&]()->int {
521a22d288SDouglas Gregor       S1 &s1 = operator=(&this->x);
5304bbab58SDouglas Gregor       return operator()(this->x + y);
5404bbab58SDouglas Gregor     }();
5504bbab58SDouglas Gregor   }
5604bbab58SDouglas Gregor };
57