1// Copyright (C) 2003 Free Software Foundation, Inc.
2// Contributed by Nathan Sidwell 30 Jul 2003 <nathan@codesourcery.com>
3
4// make sure statement expressions work properly
5
6// { dg-do run }
7// { dg-options "" }
8
9extern "C" int printf (char const *, ...);
10extern "C" void abort ();
11
12static unsigned order[] =
13{
14  1, 101, 2, 102,
15  3, 4, 104, 103,
16  5, 6, 105, 106,
17  7, 107, 8, 408, 9, 109, 108,
18  10, 11, 110, 411, 12, 112, 111,
19  13, 113,
20  14, 214, 114, 114,
21  0
22};
23
24static unsigned point;
25
26static void Check (unsigned t, unsigned i, void const *ptr, char const *name)
27{
28  printf ("%d %d %p %s\n", t, i, ptr, name);
29
30  if (order[point++] != i + t)
31    abort ();
32}
33
34template <int I> struct A
35{
36  A () { Check (0, I, this, __PRETTY_FUNCTION__); }
37  ~A () { Check (100, I, this, __PRETTY_FUNCTION__); }
38  A (A const &) { Check (200, I, this, __PRETTY_FUNCTION__); }
39  A &operator= (A const &) { Check (300, I, this, __PRETTY_FUNCTION__); }
40  void Foo () const { Check (400, I, this, __PRETTY_FUNCTION__); }
41};
42
43int main ()
44{
45  ({A<1> (); A<2> (); ;});
46  ({A<3> (), A<4> (); ;});
47  ({A<5> (), A<6> ();});
48  ({A <7> (); A<8> (); }).Foo (), A<9> ();
49  ({A <10> (), A<11> (); }).Foo (), A<12> ();
50  ({A<13> a; a; ; });
51  ({A<14> a; a; });
52  Check (0, 0, 0, "end");
53}
54