blob: e816426cbf9a801a04b9be256e4f499b9141edb8 [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() {
Douglas Gregor8c50e7c2012-02-09 00:47:04 +00005 (void)[]() -> int { }; // expected-warning{{control reaches end of non-void function}} \
Douglas Gregor21f46922012-02-08 20:17:14 +00006 // 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) {
Douglas Gregor8c50e7c2012-02-09 00:47:04 +000015 (void)[i,ic] ()->void { // expected-error{{lambda expressions are not supported yet}}
Douglas Gregorc70fe352012-02-08 20:56:50 +000016 float &fr1 = check_const_int(i);
17 float &fr2 = check_const_int(ic);
18 };
19
Douglas Gregor8c50e7c2012-02-09 00:47:04 +000020 (void)[=] ()->void { // expected-error{{lambda expressions are not supported yet}}
Douglas Gregorc70fe352012-02-08 20:56:50 +000021 float &fr1 = check_const_int(i);
22 float &fr2 = check_const_int(ic);
23 };
24
Douglas Gregor8c50e7c2012-02-09 00:47:04 +000025 (void)[i,ic] () mutable ->void { // expected-error{{lambda expressions are not supported yet}}
Douglas Gregorc70fe352012-02-08 20:56:50 +000026 int &ir = check_const_int(i);
27 float &fr = check_const_int(ic);
28 };
29
Douglas Gregor8c50e7c2012-02-09 00:47:04 +000030 (void)[=] () mutable ->void { // expected-error{{lambda expressions are not supported yet}}
Douglas Gregorc70fe352012-02-08 20:56:50 +000031 int &ir = check_const_int(i);
32 float &fr = check_const_int(ic);
33 };
34
Douglas Gregor8c50e7c2012-02-09 00:47:04 +000035 (void)[&i,&ic] ()->void { // expected-error{{lambda expressions are not supported yet}}
Douglas Gregorc70fe352012-02-08 20:56:50 +000036 int &ir = check_const_int(i);
37 float &fr = check_const_int(ic);
38 };
39
Douglas Gregor8c50e7c2012-02-09 00:47:04 +000040 (void)[&] ()->void { // expected-error{{lambda expressions are not supported yet}}
Douglas Gregorc70fe352012-02-08 20:56:50 +000041 int &ir = check_const_int(i);
42 float &fr = check_const_int(ic);
43 };
44}
Douglas Gregor21f46922012-02-08 20:17:14 +000045
46