diff options
author | Douglas Gregor <dgregor@apple.com> | 2009-12-16 18:50:27 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2009-12-16 18:50:27 +0000 |
commit | 4f4b18621561084bb55a38ee808d30009dd8fec1 (patch) | |
tree | e7e5a1ead9d416169028c986062b7ffc60f0e101 /clang/test | |
parent | 22a8a4bfb95d63fc83869c490afc42c693def07c (diff) | |
download | bcm5719-llvm-4f4b18621561084bb55a38ee808d30009dd8fec1.tar.gz bcm5719-llvm-4f4b18621561084bb55a38ee808d30009dd8fec1.zip |
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.
llvm-svn: 91548
Diffstat (limited to 'clang/test')
-rw-r--r-- | clang/test/CodeGenCXX/value-init.cpp | 25 | ||||
-rw-r--r-- | clang/test/SemaCXX/dcl_init_aggr.cpp | 9 |
2 files changed, 30 insertions, 4 deletions
diff --git a/clang/test/CodeGenCXX/value-init.cpp b/clang/test/CodeGenCXX/value-init.cpp new file mode 100644 index 00000000000..decfc18e594 --- /dev/null +++ b/clang/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) +} diff --git a/clang/test/SemaCXX/dcl_init_aggr.cpp b/clang/test/SemaCXX/dcl_init_aggr.cpp index a900411b980..f7dc8f11c70 100644 --- a/clang/test/SemaCXX/dcl_init_aggr.cpp +++ b/clang/test/SemaCXX/dcl_init_aggr.cpp @@ -40,17 +40,18 @@ char cv[4] = { 'a', 's', 'd', 'f', 0 }; // expected-error{{excess elements in ar struct TooFew { int a; char* b; int c; }; TooFew too_few = { 1, "asdf" }; // okay -struct NoDefaultConstructor { // expected-note 3 {{candidate function}} +struct NoDefaultConstructor { // expected-note 3 {{candidate function}} \ + // expected-note{{declared here}} NoDefaultConstructor(int); // expected-note 3 {{candidate function}} }; -struct TooFewError { +struct TooFewError { // expected-error{{implicit default constructor for}} int a; - NoDefaultConstructor nodef; + NoDefaultConstructor nodef; // expected-note{{member is declared here}} }; TooFewError too_few_okay = { 1, 1 }; TooFewError too_few_error = { 1 }; // expected-error{{no matching constructor}} -TooFewError too_few_okay2[2] = { 1, 1 }; +TooFewError too_few_okay2[2] = { 1, 1 }; // expected-note{{implicit default constructor for 'struct TooFewError' first required here}} TooFewError too_few_error2[2] = { 1 }; // expected-error{{no matching constructor}} NoDefaultConstructor too_few_error3[3] = { }; // expected-error {{no matching constructor}} |