FSF GCC merge 02/23/03
[official-gcc.git] / gcc / testsuite / g++.old-deja / g++.jason / cond2.C
blob9a8e04546ee86ec0367271a16127a3cadecc11e3
1 // Positive testcase for decls in conditions.
3 extern "C" int printf(const char *, ...);
5 int up = 0;
6 int down = 0;
8 struct T
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; }
17 int main ()
19   int t;
21   if (T t = 1)
22     ;
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     ;
46   printf ("\n");
47   
48   for (int k = 3; T t = k--;)
49     ;
51   printf ("\n");
52   
53   switch (T t = 34)
54     {
55     case 34:
56       ;
57     }
59   printf ("\n");
60   
61   if (up == down && up == 18)
62     return 0;
63   else
64     return 1;