summaryrefslogtreecommitdiffstats
path: root/clang/test/CXX/class/class.static/class.static.data/p3.cpp
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2012-02-13 03:54:03 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2012-02-13 03:54:03 +0000
commit3607ffee5ccaab26be4e99f9beabb4a6c84f2700 (patch)
tree7ebec671a00bf2a92cee0b1b80f1ec6302ef416b /clang/test/CXX/class/class.static/class.static.data/p3.cpp
parent779579b332f55e2a5852c65b4085e4705af9f42c (diff)
downloadbcm5719-llvm-3607ffee5ccaab26be4e99f9beabb4a6c84f2700.tar.gz
bcm5719-llvm-3607ffee5ccaab26be4e99f9beabb4a6c84f2700.zip
Update constexpr implementation to match CWG's chosen approach for core issues
1358, 1360, 1452 and 1453. - Instantiations of constexpr functions are always constexpr. This removes the need for separate declaration/definition checking, which is now gone. - This makes it possible for a constexpr function to be virtual, if they are only dependently virtual. Virtual calls to such functions are not constant expressions. - Likewise, it's now possible for a literal type to have virtual base classes. A constexpr constructor for such a type cannot actually produce a constant expression, though, so add a special-case diagnostic for a constructor call to such a type rather than trying to evaluate it. - Classes with trivial default constructors (for which value initialization can produce a fully-initialized value) are considered literal types. - Classes with volatile members are not literal types. - constexpr constructors can be members of non-literal types. We do not yet use static initialization for global objects constructed in this way. llvm-svn: 150359
Diffstat (limited to 'clang/test/CXX/class/class.static/class.static.data/p3.cpp')
-rw-r--r--clang/test/CXX/class/class.static/class.static.data/p3.cpp7
1 files changed, 3 insertions, 4 deletions
diff --git a/clang/test/CXX/class/class.static/class.static.data/p3.cpp b/clang/test/CXX/class/class.static/class.static.data/p3.cpp
index fed715e2190..fef9a7dae16 100644
--- a/clang/test/CXX/class/class.static/class.static.data/p3.cpp
+++ b/clang/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 {
+struct NonLit { // expected-note {{no constexpr constructors}}
NonLit();
};
@@ -29,15 +29,14 @@ template<typename T>
struct U {
static constexpr int a = 0;
static constexpr int b; // expected-error {{declaration of constexpr static data member 'b' requires an initializer}}
- // FIXME: It'd be nice to error on this at template definition time.
- static constexpr NonLit h = NonLit(); // expected-error 2{{must be initialized by a constant expression}} expected-note 2{{non-literal type}}
+ 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 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'}}
-U<int> u1; // expected-note {{here}}
+U<int> u1;
U<NonLit> u2; // expected-note {{here}}
static_assert(U<int>::a == 0, "");
OpenPOWER on IntegriCloud