diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2012-02-13 03:54:03 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2012-02-13 03:54:03 +0000 |
commit | 86c3ae46250cdcc57778c27826060779a92f3815 (patch) | |
tree | 0d448fb2248c76e1339de8ad2c8c28d2b08d9b14 /test/CXX/special | |
parent | 9b338a7bca39a68ae9f8c57d9210f19f7e45b665 (diff) |
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.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150359 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/CXX/special')
-rw-r--r-- | test/CXX/special/class.ctor/p6-0x.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/test/CXX/special/class.ctor/p6-0x.cpp b/test/CXX/special/class.ctor/p6-0x.cpp index 71afd244bd..8c8800f2de 100644 --- a/test/CXX/special/class.ctor/p6-0x.cpp +++ b/test/CXX/special/class.ctor/p6-0x.cpp @@ -11,7 +11,7 @@ struct NonConstexpr2 { // expected-note {{here}} struct NonConstexpr2a : NonConstexpr1 { }; constexpr NonConstexpr1 nc1 = NonConstexpr1(); // ok, does not call constructor constexpr NonConstexpr2 nc2 = NonConstexpr2(); // ok, does not call constructor -constexpr NonConstexpr2a nc2a = NonConstexpr2a(); // expected-error {{constant expression}} expected-note {{non-literal type 'const NonConstexpr2a'}} +constexpr NonConstexpr2a nc2a = NonConstexpr2a(); // ok, does not call constructor constexpr int nc2_a = NonConstexpr2().nl.a; // ok constexpr int nc2a_a = NonConstexpr2a().a; // ok struct Helper { @@ -21,8 +21,8 @@ struct Helper { struct Constexpr1 {}; constexpr Constexpr1 c1 = Constexpr1(); // ok -struct NonConstexpr3 : virtual Constexpr1 {}; -constexpr NonConstexpr3 nc3 = NonConstexpr3(); // expected-error {{constant expression}} expected-note {{non-literal type 'const NonConstexpr3'}} +struct NonConstexpr3 : virtual Constexpr1 {}; // expected-note {{struct with virtual base}} expected-note {{declared here}} +constexpr NonConstexpr3 nc3 = NonConstexpr3(); // expected-error {{non-literal type 'const NonConstexpr3'}} struct Constexpr2 { int a = 0; |