Files
clang-p2996/clang/test/CXX/expr/expr.prim/expr.prim.lambda/p7.cpp
Douglas Gregor c70fe353ea When computing the type of a local variable reference within a lambda,
only add 'const' for variables captured by copy in potentially
evaluated expressions of non-mutable lambdas. (The "by copy" part was
missing).

llvm-svn: 150088
2012-02-08 20:56:50 +00:00

46 lines
1.5 KiB
C++

// RUN: %clang_cc1 -fsyntax-only -std=c++11 %s -verify
// Check that analysis-based warnings work in lambda bodies.
void analysis_based_warnings() {
[]() -> int { }; // expected-warning{{control reaches end of non-void function}} \
// expected-error{{lambda expressions are not supported yet}}
}
// Check that we get the right types of captured variables (the semantic-analysis part of
int &check_const_int(int&);
float &check_const_int(const int&);
void test_capture_constness(int i, const int ic) {
[i,ic] ()->void { // expected-error{{lambda expressions are not supported yet}}
float &fr1 = check_const_int(i);
float &fr2 = check_const_int(ic);
};
[=] ()->void { // expected-error{{lambda expressions are not supported yet}}
float &fr1 = check_const_int(i);
float &fr2 = check_const_int(ic);
};
[i,ic] () mutable ->void { // expected-error{{lambda expressions are not supported yet}}
int &ir = check_const_int(i);
float &fr = check_const_int(ic);
};
[=] () mutable ->void { // expected-error{{lambda expressions are not supported yet}}
int &ir = check_const_int(i);
float &fr = check_const_int(ic);
};
[&i,&ic] ()->void { // expected-error{{lambda expressions are not supported yet}}
int &ir = check_const_int(i);
float &fr = check_const_int(ic);
};
[&] ()->void { // expected-error{{lambda expressions are not supported yet}}
int &ir = check_const_int(i);
float &fr = check_const_int(ic);
};
}