OSDN Git Service

new
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / g++.old-deja / g++.jason / cond2.C
1 // Positive testcase for decls in conditions.
2
3 extern "C" int printf(const char *, ...);
4
5 int up = 0;
6 int down = 0;
7
8 struct T
9 {
10   int i;
11   T(int j) { i = j; printf("UP\n"); up++; }
12   T(const T& t) { i = t.i; printf("unwanted copy\n"); }
13   ~T() { printf ("DOWN\n"); down++; }
14   operator int () { return i; }
15 };
16
17 main ()
18 {
19   int t;
20
21   if (T t = 1)
22     ;
23
24   printf ("\n");
25   
26   int j = 3;
27   while (T t = j--)
28     ;
29   
30   printf ("\n");
31   
32   j = 3;
33   while (1)
34     {
35       T t = j--;
36       if (t) continue;
37       break;
38     }
39   
40   printf ("\n");
41   
42   j = 3;
43   for (;T t = j--;)
44     ;
45
46   printf ("\n");
47   
48   for (int k = 3; T t = k--;)
49     ;
50
51   printf ("\n");
52   
53   switch (T t = 34)
54     {
55     case 34:
56       ;
57     }
58
59   printf ("\n");
60   
61   if (up == down && up == 18)
62     return 0;
63   else
64     return 1;
65 }