doc: Document struct-layout-1.exp for ABI checks
[official-gcc.git] / gcc / testsuite / g++.dg / init / aggr7-eh.C
blobdb45e15d9af70074d17e12712434362b227e6c23
1 // PR c++/50866, adjusted
2 // { dg-do run }
4 #if __cplusplus > 201100L
5 #define THROWING noexcept(false)
6 #else
7 #define THROWING
8 #endif
10 extern "C" void abort ();
12 int a;
13 int d = -1;
14 struct A {
15   A() { ++a; }
16   A(const A&);
17   ~A() THROWING {
18     --a;
19     if (a == d)
20       throw (short)a;
21   }
23 int b;
24 int t;
25 struct B {
26   B(const char *, const A& = A())
27   {
28     if (b == t)
29       throw b;
30     ++b;
31     if (a != b) abort ();
32   }
33   B(const B&);
34   ~B()
35   {
36     --b;
37   }
39 struct C {
40   B b1, b2, b3;
42 void f()
44   try
45     {
46       C c = { "a","b","c" };
47       if (a != 0) abort ();
48       if (b != 3) abort ();
49     }
50   catch (int i) { }
51   catch (short s) { }
52   if (a != 0) abort ();
53   if (b != 0) abort ();
56 int main()
58   for (t = 0; t <= 3; ++t)
59     f();
60   for (d = 0; d <= 2; ++d)
61     f();