diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2012-03-02 04:14:40 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2012-03-02 04:14:40 +0000 |
commit | 35ecb36fcd71f113a1c574bd4f7cd2d32d033213 (patch) | |
tree | 4f9ab5429888b534b6e1b5b95c481414957f73a1 /clang/test/SemaCXX/lambda-expressions.cpp | |
parent | 545f38c3d2ecb4785ad33d90887831e1e6057b25 (diff) | |
download | bcm5719-llvm-35ecb36fcd71f113a1c574bd4f7cd2d32d033213.tar.gz bcm5719-llvm-35ecb36fcd71f113a1c574bd4f7cd2d32d033213.zip |
Ensure that we instantiate static reference data members of class templates
early, since their values can be used in constant expressions in C++11. For
odr-use checking, the opposite change is required, since references are
odr-used whether or not they satisfy the requirements for appearing in a
constant expression.
llvm-svn: 151881
Diffstat (limited to 'clang/test/SemaCXX/lambda-expressions.cpp')
-rw-r--r-- | clang/test/SemaCXX/lambda-expressions.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/clang/test/SemaCXX/lambda-expressions.cpp b/clang/test/SemaCXX/lambda-expressions.cpp index 7e53754a527..9d3f9b857f3 100644 --- a/clang/test/SemaCXX/lambda-expressions.cpp +++ b/clang/test/SemaCXX/lambda-expressions.cpp @@ -85,6 +85,13 @@ namespace ImplicitCapture { const int h = a; // expected-note {{declared}} []() { return h; }; // expected-error {{variable 'h' cannot be implicitly captured in a lambda with no capture-default specified}} expected-note {{lambda expression begins here}} + + // The exemption for variables which can appear in constant expressions + // applies only to objects (and not to references). + // FIXME: This might be a bug in the standard. + static int i; + constexpr int &ref_i = i; // expected-note {{declared}} + [] { return ref_i; }; // expected-error {{variable 'ref_i' cannot be implicitly captured in a lambda with no capture-default specified}} expected-note {{lambda expression begins here}} } } |