summaryrefslogtreecommitdiffstats
path: root/test/CodeGenCXX/value-init.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2009-12-16 18:50:27 +0000
committerDouglas Gregor <dgregor@apple.com>2009-12-16 18:50:27 +0000
commit16006c901315fa12a108b4e571f187f4b676e426 (patch)
tree0a429cf4eeeadf701786ee980d6f47d55bccb0ac /test/CodeGenCXX/value-init.cpp
parent79433b59915859126a774fcd09fa32d7d5a1a3ef (diff)
When value-initializing a class with no user-defined constructors but
with a non-trivial default constructor, zero-initialize the storage and then call the default constructor. Fixes PR5800. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91548 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/CodeGenCXX/value-init.cpp')
-rw-r--r--test/CodeGenCXX/value-init.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/test/CodeGenCXX/value-init.cpp b/test/CodeGenCXX/value-init.cpp
new file mode 100644
index 0000000000..decfc18e59
--- /dev/null
+++ b/test/CodeGenCXX/value-init.cpp
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 %s -triple x86_64-apple-darwin10 -emit-llvm -o - | FileCheck %s
+
+struct A {
+ virtual ~A();
+};
+
+struct B : A { };
+
+struct C {
+ int i;
+ B b;
+};
+
+// CHECK: _Z15test_value_initv
+void test_value_init() {
+ // This value initialization requires zero initialization of the 'B'
+ // subobject followed by a call to its constructor.
+ // PR5800
+
+ // CHECK: store i32 17
+ // CHECK: call void @llvm.memset.i64
+ // CHECK: call void @_ZN1BC1Ev(%struct.A* %tmp1)
+ C c = { 17 } ;
+ // CHECK: call void @_ZN1CD1Ev(%struct.C* %c)
+}