1// { dg-do run } 2 3 4// Copyright (C) 2003 Free Software Foundation, Inc. 5// Contributed by Nathan Sidwell 30 Jul 2003 <nathan@codesourcery.com> 6 7// compound exprs were causing additional temporaries. 8 9extern "C" int printf (char const *, ...); 10extern "C" void abort (); 11 12 13static unsigned order[] = 14{ 15 1, 2, 502, 102, 101, 16 0 17}; 18 19static unsigned point; 20 21static void Check (unsigned t, unsigned i, void const *ptr, char const *name) 22{ 23 printf ("%d %d %p %s\n", t, i, ptr, name); 24 25 if (order[point++] != i + t) 26 abort (); 27 28} 29 30template <int I> struct A 31{ 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__); } 37}; 38 39template <int I> void Foo (A<I> a) 40{ 41 Check (500, I, &a, __PRETTY_FUNCTION__); 42} 43 44int main () 45{ 46 Foo ((A<1> (), A<2> ())); 47 Check (0, 0, 0, "end"); 48} 49