diff options
Diffstat (limited to 'gcc/testsuite/g++.dg/ext/complit12.C')
-rw-r--r-- | gcc/testsuite/g++.dg/ext/complit12.C | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/gcc/testsuite/g++.dg/ext/complit12.C b/gcc/testsuite/g++.dg/ext/complit12.C new file mode 100644 index 00000000000..81056214483 --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/complit12.C @@ -0,0 +1,54 @@ +// PR c++/40948 +// { dg-do run } +// { dg-options "" } + +int c; +struct M +{ + M () { ++c; } + M (const M&) { ++c; } + ~M () { --c; } +}; + +struct S +{ + S (); + M m[1]; +}; + +S::S () : m ((M[1]) { M () }) +{ +} + +struct T +{ + T (); + M m[4]; +}; + +T::T () : m ((M[4]) { M (), M (), M (), M () }) +{ +} + +int main () +{ + { + M m[1] = (M[1]) { M () }; + if (c != 1) + return 1; + M n = (M) { M () }; + if (c != 2) + return 2; + M o[4] = (M[4]) { M (), M (), M (), M () }; + if (c != 6) + return 3; + S s; + if (c != 7) + return 4; + T t; + if (c != 11) + return 5; + } + if (c != 0) + return 6; +} |