OSDN Git Service

revert accidentally committed changes
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / g++.dg / ext / stmtexpr2.C
1 // { dg-do run }
2 // { dg-options "" }
3
4 extern "C" int printf (char const *, ...);
5 extern "C" void abort ();
6
7 // There are two alternate legal renderings.
8 static unsigned int alt1[] = { 11, 10, 21, 110, 111, 121 };
9 static unsigned int alt2[] = { 10, 11, 21, 111, 110, 121 };
10
11 static unsigned int pointer = 0;
12 static unsigned int *which;
13
14 static void Check (unsigned t, unsigned i, void const *ptr, char const *name)
15 {
16   printf ("%d %d %p %s\n", t, i, ptr, name);
17
18   if (pointer > sizeof(alt1)/sizeof(alt1[0]))
19     abort ();
20   if (pointer == 0)
21     {
22       if (t + i == alt1[0])
23         which = &alt1[0];
24       else if (t + i == alt2[0])
25         which = &alt2[0];
26       else
27         abort ();
28     }
29   else if (t + i != which[pointer])
30     abort ();
31   pointer++;
32 }
33
34 struct A 
35 {
36   int I;
37
38   A (int i) : I(i) { Check (0, I, this, __PRETTY_FUNCTION__); }
39   ~A () { Check (100, I, this, __PRETTY_FUNCTION__); }
40   A (A const &a) : I(a.I) { Check (200, I, this, __PRETTY_FUNCTION__); }
41   A &operator= (A const &a)
42   { I = a.I; Check (300, I, this, __PRETTY_FUNCTION__); return *this; }
43   void Foo () const { Check (400, I, this, __PRETTY_FUNCTION__); }
44   A operator+ (A const &a) const
45   { return A(I + a.I); }
46 };
47
48 int main ()
49 {
50   ({ A(10) + A(11); });
51 }