diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2012-02-23 08:33:23 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2012-02-23 08:33:23 +0000 |
commit | c22adbd40ac2fc445e41fb664777179aa5c522e3 (patch) | |
tree | c76a954e5a4a443f3aaedaa3637d8c20f99f348d /test/CodeGenCXX/const-init-cxx11.cpp | |
parent | b11e52540166a2958439cfe562c25931e4460759 (diff) |
PR12067: When emitting an evaluated constant structure in C++11 mode, don't
forget the vptrs.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151245 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/CodeGenCXX/const-init-cxx11.cpp')
-rw-r--r-- | test/CodeGenCXX/const-init-cxx11.cpp | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/test/CodeGenCXX/const-init-cxx11.cpp b/test/CodeGenCXX/const-init-cxx11.cpp index 0ff8d10f67..5366d6d485 100644 --- a/test/CodeGenCXX/const-init-cxx11.cpp +++ b/test/CodeGenCXX/const-init-cxx11.cpp @@ -254,6 +254,42 @@ namespace NonLiteralConstexpr { } } +// PR12067 +namespace VirtualMembers { + struct A { + constexpr A(double d) : d(d) {} + virtual void f(); + double d; + }; + struct B : A { + constexpr B() : A(2.0), c{'h', 'e', 'l', 'l', 'o'} {} + constexpr B(int n) : A(n), c{'w', 'o', 'r', 'l', 'd'} {} + virtual void g(); + char c[5]; + }; + struct C { + constexpr C() : n(64) {} + int n; + }; + struct D : C, A, B { + constexpr D() : A(1.0), B(), s(5) {} + short s; + }; + struct E : D, B { + constexpr E() : B(3), c{'b','y','e'} {} + char c[3]; + }; + + // CHECK: @_ZN14VirtualMembers1eE = global { i8**, double, i32, i8**, double, [5 x i8], i16, i8**, double, [5 x i8], [3 x i8] } { i8** getelementptr inbounds ([11 x i8*]* @_ZTVN14VirtualMembers1EE, i64 0, i64 2), double 1.000000e+00, i32 64, i8** getelementptr inbounds ([11 x i8*]* @_ZTVN14VirtualMembers1EE, i64 0, i64 5), double 2.000000e+00, [5 x i8] c"hello", i16 5, i8** getelementptr inbounds ([11 x i8*]* @_ZTVN14VirtualMembers1EE, i64 0, i64 9), double 3.000000e+00, [5 x i8] c"world", [3 x i8] c"bye" } + E e; + + struct nsMemoryImpl { + virtual void f(); + }; + // CHECK: @_ZN14VirtualMembersL13sGlobalMemoryE = internal global { i8** } { i8** getelementptr inbounds ([3 x i8*]* @_ZTVN14VirtualMembers12nsMemoryImplE, i64 0, i64 2) } + static nsMemoryImpl sGlobalMemory; +} + // Constant initialization tests go before this point, // dynamic initialization tests go after. |