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 | 16581335fc32abcbc6ab14eda7af38cf759664b7 (patch) | |
tree | ee8e69c07d34c7c01643e5cdbd2be42e7aed780c /test/SemaCXX/lambda-expressions.cpp | |
parent | 0524171a57e6f9f6ee79c02ed4e20c5914d8b2db (diff) |
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.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151881 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/SemaCXX/lambda-expressions.cpp')
-rw-r--r-- | test/SemaCXX/lambda-expressions.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/test/SemaCXX/lambda-expressions.cpp b/test/SemaCXX/lambda-expressions.cpp index 7e53754a52..9d3f9b857f 100644 --- a/test/SemaCXX/lambda-expressions.cpp +++ b/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}} } } |