diff options
author | upstream source tree <ports@midipix.org> | 2015-03-15 20:14:05 -0400 |
---|---|---|
committer | upstream source tree <ports@midipix.org> | 2015-03-15 20:14:05 -0400 |
commit | 554fd8c5195424bdbcabf5de30fdc183aba391bd (patch) | |
tree | 976dc5ab7fddf506dadce60ae936f43f58787092 /gcc/testsuite/g++.dg/cpp0x/union3.C | |
download | cbb-gcc-4.6.4-15d2061ac0796199866debe9ac87130894b0cdd3.tar.bz2 cbb-gcc-4.6.4-15d2061ac0796199866debe9ac87130894b0cdd3.tar.xz |
obtained gcc-4.6.4.tar.bz2 from upstream website;upstream
verified gcc-4.6.4.tar.bz2.sig;
imported gcc-4.6.4 source tree from verified upstream tarball.
downloading a git-generated archive based on the 'upstream' tag
should provide you with a source tree that is binary identical
to the one extracted from the above tarball.
if you have obtained the source via the command 'git clone',
however, do note that line-endings of files in your working
directory might differ from line-endings of the respective
files in the upstream repository.
Diffstat (limited to 'gcc/testsuite/g++.dg/cpp0x/union3.C')
-rw-r--r-- | gcc/testsuite/g++.dg/cpp0x/union3.C | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/gcc/testsuite/g++.dg/cpp0x/union3.C b/gcc/testsuite/g++.dg/cpp0x/union3.C new file mode 100644 index 000000000..f1e8ddb61 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/union3.C @@ -0,0 +1,69 @@ +// Runtime test for C++0x unrestricted unions +// { dg-options -std=c++0x } +// { dg-do run } + +int c, d; +struct A +{ + int i; + A(): i(1) { ++c; } + A(const A&): i(2) { ++c; } + ~A() { ++d; } +}; + +union B +{ + A a; + B() { } + B(const B& b) { } + ~B() { } +}; + +struct C +{ + union { A a; }; + C() { } + C(const C&) { } + ~C() { } +}; + +union D +{ + A a; + D(): a() { } + D(const D& d): a(d.a) { } + ~D() { a.~A(); } +}; + +struct E +{ + union { A a; }; + E(): a() { } + E(const E& e): a (e.a) { } + ~E() { a.~A(); } +}; + +int main() +{ + { + B b1; + B b2(b1); + + C c1; + C c2(c1); + } + + if (c != 0 || d != 0) + return c+d*10; + + { + D d1; + D d2(d1); + + E e1; + E e2(e1); + } + + if (c != 4 || d != 4) + return c*100+d*1000; +} |