Merge from mainline (gomp-merge-2005-02-26).
[official-gcc.git] / gcc / testsuite / g++.old-deja / g++.other / empty1.C
blob47a5b7a51e1fcba61ee2b0dc163c7a9d505360d3
1 // { dg-do run  }
2 // Origin: Mark Mitchell <mark@codesourcery.com>
3 // This test case checks that the return value optimization works for
4 // empty classes.
6 // PR c++/5995
8 extern "C" void abort();
9 extern "C" int printf (const char *, ...);
11 int i;
13 struct A;
15 struct A* as[10];
17 struct A {
18   A () { as[i++] = this; }
19   A (const A&) { as[i++] = this; }
20   ~A() { if (i == 0 || as[--i] != this) abort(); }
23 A f() { return A(); }
25 int main ()
27   A a (f ());