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/SemaTemplate/constexpr-instantiate.cpp | |
parent | 0524171a57e6f9f6ee79c02ed4e20c5914d8b2db (diff) | |
download | clang-16581335fc32abcbc6ab14eda7af38cf759664b7.tar.gz clang-16581335fc32abcbc6ab14eda7af38cf759664b7.tar.bz2 clang-16581335fc32abcbc6ab14eda7af38cf759664b7.tar.xz |
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/SemaTemplate/constexpr-instantiate.cpp')
-rw-r--r-- | test/SemaTemplate/constexpr-instantiate.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/test/SemaTemplate/constexpr-instantiate.cpp b/test/SemaTemplate/constexpr-instantiate.cpp index 316b088566..2f9fe0e485 100644 --- a/test/SemaTemplate/constexpr-instantiate.cpp +++ b/test/SemaTemplate/constexpr-instantiate.cpp @@ -65,3 +65,13 @@ namespace DataMember { constexpr int m = S<int>::k; // ok constexpr int o = n; // expected-error {{constant expression}} expected-note {{initializer of 'n'}} } + +namespace Reference { + const int k = 5; + template<typename T> struct S { + static volatile int &r; + }; + template<typename T> volatile int &S<T>::r = const_cast<volatile int&>(k); + constexpr int n = const_cast<int&>(S<int>::r); + static_assert(n == 5, ""); +} |