2003-12-26 Guilhem Lavaux <guilhem@kaffe.org>
[official-gcc.git] / gcc / testsuite / g++.dg / opt / tmp1.C
blob21665335e7234e8990e64b41ecce8b9ff38ba0b5
1 // { dg-do run }
4 // Copyright (C) 2003 Free Software Foundation, Inc.
5 // Contributed by Nathan Sidwell 30 Jul 2003 <nathan@codesourcery.com>
7 // compound exprs were causing additional temporaries.
9 extern "C" int printf (char const *, ...);
10 extern "C" void abort ();
13 static unsigned order[] = 
15   1, 2, 502, 102, 101,
16   0
19 static unsigned point;
21 static void Check (unsigned t, unsigned i, void const *ptr, char const *name)
23   printf ("%d %d %p %s\n", t, i, ptr, name);
24   
25   if (order[point++] != i + t)
26     abort ();
27   
30 template <int I> struct A 
32   A () { Check (0, I, this, __PRETTY_FUNCTION__); }
33   ~A () { Check (100, I, this, __PRETTY_FUNCTION__); }
34   A (A const &) { Check (200, I, this, __PRETTY_FUNCTION__); }
35   A &operator= (A const &) { Check (300, I, this, __PRETTY_FUNCTION__); }
36   void Foo () const { Check (400, I, this, __PRETTY_FUNCTION__); }
39 template <int I> void Foo (A<I> a)
41   Check (500, I, &a, __PRETTY_FUNCTION__);
44 int main ()
46   Foo ((A<1> (), A<2> ()));
47   Check (0, 0, 0, "end");