diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2012-02-13 22:16:19 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2012-02-13 22:16:19 +0000 |
commit | 7ca4850a3e3530fa6c93b64b740446e32c97f992 (patch) | |
tree | 4bdd8740e76bd15404199f6d10d6930bbab91cf3 /test/CXX/class/class.static/class.static.data/p3.cpp | |
parent | 5ad3af90dd09b482c61dca565be4b50efcd8021d (diff) |
Deal with a horrible C++11 special case. If a non-literal type has a constexpr
constructor, and that constructor is used to initialize an object of static
storage duration such that all members and bases are initialized by constant
expressions, constant initialization is performed. In this case, the object
can still have a non-trivial destructor, and if it does, we must emit a dynamic
initializer which performs no initialization and instead simply registers that
destructor.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150419 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/CXX/class/class.static/class.static.data/p3.cpp')
-rw-r--r-- | test/CXX/class/class.static/class.static.data/p3.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/test/CXX/class/class.static/class.static.data/p3.cpp b/test/CXX/class/class.static/class.static.data/p3.cpp index fef9a7dae1..117997ee28 100644 --- a/test/CXX/class/class.static/class.static.data/p3.cpp +++ b/test/CXX/class/class.static/class.static.data/p3.cpp @@ -1,6 +1,6 @@ // RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s -struct NonLit { // expected-note {{no constexpr constructors}} +struct NonLit { // expected-note 3{{no constexpr constructors}} NonLit(); }; @@ -30,11 +30,11 @@ struct U { static constexpr int a = 0; static constexpr int b; // expected-error {{declaration of constexpr static data member 'b' requires an initializer}} static constexpr NonLit h = NonLit(); // expected-error {{cannot have non-literal type 'const NonLit'}} - static constexpr T c = T(); // expected-error {{must be initialized by a constant expression}} expected-note {{non-literal type}} + static constexpr T c = T(); // expected-error {{cannot have non-literal type}} static const T d; }; -template<typename T> constexpr T U<T>::d = T(); // expected-error {{must be initialized by a constant expression}} expected-note {{non-literal type 'const NonLit'}} +template<typename T> constexpr T U<T>::d = T(); // expected-error {{non-literal type 'const NonLit'}} U<int> u1; U<NonLit> u2; // expected-note {{here}} |