2003-12-26 Guilhem Lavaux <guilhem@kaffe.org>
[official-gcc.git] / gcc / testsuite / g++.dg / ext / stmtexpr1.C
blobafdf64403177e272196948f8cfffe08b632e04e0
1 // { dg-do run }
2 // { dg-options "" }
4 // Copyright (C) 2003 Free Software Foundation, Inc.
5 // Contributed by Nathan Sidwell 30 Jul 2003 <nathan@codesourcery.com>
7 // make statement expressions work properly
9 extern "C" int printf (char const *, ...);
10 extern "C" void abort ();
12 static unsigned order[] = 
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
24 static unsigned point;
26 static void Check (unsigned t, unsigned i, void const *ptr, char const *name)
28   printf ("%d %d %p %s\n", t, i, ptr, name);
29   
30   if (order[point++] != i + t)
31     abort ();
34 template <int I> struct A 
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__); }
43 int main ()
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");