blob: 3c5ac220a1e8e7628f24b8b3793e5a5bc75fabb0 [file] [log] [blame]
Douglas Gregor21f46922012-02-08 20:17:14 +00001// RUN: %clang_cc1 -fsyntax-only -std=c++11 %s -verify
2
3// Check that analysis-based warnings work in lambda bodies.
4void analysis_based_warnings() {
5 []() -> int { }; // expected-warning{{control reaches end of non-void function}} \
6 // expected-error{{lambda expressions are not supported yet}}
7}
8
Douglas Gregor8390afd2012-02-08 21:19:04 +00009// Check that we get the right types of captured variables (the
10// semantic-analysis part of p7).
Douglas Gregorc70fe352012-02-08 20:56:50 +000011int &check_const_int(int&);
12float &check_const_int(const int&);
13
14void test_capture_constness(int i, const int ic) {
15 [i,ic] ()->void { // expected-error{{lambda expressions are not supported yet}}
16 float &fr1 = check_const_int(i);
17 float &fr2 = check_const_int(ic);
18 };
19
20 [=] ()->void { // expected-error{{lambda expressions are not supported yet}}
21 float &fr1 = check_const_int(i);
22 float &fr2 = check_const_int(ic);
23 };
24
25 [i,ic] () mutable ->void { // expected-error{{lambda expressions are not supported yet}}
26 int &ir = check_const_int(i);
27 float &fr = check_const_int(ic);
28 };
29
30 [=] () mutable ->void { // expected-error{{lambda expressions are not supported yet}}
31 int &ir = check_const_int(i);
32 float &fr = check_const_int(ic);
33 };
34
35 [&i,&ic] ()->void { // expected-error{{lambda expressions are not supported yet}}
36 int &ir = check_const_int(i);
37 float &fr = check_const_int(ic);
38 };
39
40 [&] ()->void { // expected-error{{lambda expressions are not supported yet}}
41 int &ir = check_const_int(i);
42 float &fr = check_const_int(ic);
43 };
44}
Douglas Gregor21f46922012-02-08 20:17:14 +000045
46