diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2009-08-08 23:32:22 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2009-08-08 23:32:22 +0000 |
commit | 942f4f33d02dba823594bd2d7b3d317cb01c74f8 (patch) | |
tree | f1507f680daf5b9c6d7638ae0a84de147473fc56 /test/CodeGenCXX/copy-constructor-synthesis.cpp | |
parent | 89ed31d3f9eeb8ec77c284a5cf404a74bf5e7acf (diff) | |
download | clang-942f4f33d02dba823594bd2d7b3d317cb01c74f8.tar.gz |
ir-gen for initialization, in synthesize copy constructor,
of base/field which have trivial copy constructor.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@78516 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/CodeGenCXX/copy-constructor-synthesis.cpp')
-rw-r--r-- | test/CodeGenCXX/copy-constructor-synthesis.cpp | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/test/CodeGenCXX/copy-constructor-synthesis.cpp b/test/CodeGenCXX/copy-constructor-synthesis.cpp new file mode 100644 index 0000000000..edc0c0ecb8 --- /dev/null +++ b/test/CodeGenCXX/copy-constructor-synthesis.cpp @@ -0,0 +1,55 @@ +// RUNX: clang-cc -triple x86_64-apple-darwin -S %s -o %t-64.s && +// RUNX: FileCheck -check-prefix LP64 --input-file=%t-64.s %s && +// RUN: clang-cc -triple i386-apple-darwin -S %s -o %t-32.s && +// RUN: FileCheck -check-prefix LP32 --input-file=%t-32.s %s && +// RUN: true + +extern "C" int printf(...); + +int init = 100; + +struct M { + int iM; + M() : iM(init++) {} +}; + +struct N { + int iN; + N() : iN(200) {} + N(N const & arg){this->iN = arg.iN; } +}; + +struct P { + int iP; + P() : iP(init++) {} +}; + + +struct X : M, N, P { // ... + X(){} + P p0; + void pr() { printf("iM = %d iN = %d, m1.iM = %d\n", iM, iN, m1.iM); + printf("im = %d p0.iP = %d, p1.iP = %d\n", iP, p0.iP, p1.iP); } + M m1; + P p1; +}; + +int main() +{ + X a; + X b(a); + b.pr(); + X x; + X c(x); + c.pr(); +} +#if 0 +// -m64 does not work due to unrelated llvm bug! +// CHECK-LP64: .globl __ZN1XC1ERK1X +// CHECK-LP64: .weak_definition __ZN1XC1ERK1X +// CHECK-LP64: __ZN1XC1ERK1X: +#endif + +// CHECK-LP32: .globl __ZN1XC1ERK1X +// CHECK-LP32: .weak_definition __ZN1XC1ERK1X +// CHECK-LP32: __ZN1XC1ERK1X: |