aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/g++.old-deja/g++.jason/cond2.C
blob: d1ff6a9c70d15644d04379edc009919b12436f1e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// { dg-do run  }
// Positive testcase for decls in conditions.

extern "C" int printf(const char *, ...);

int up = 0;
int down = 0;

struct T
{
  int i;
  T(int j) { i = j; printf("UP\n"); up++; }
  T(const T& t) { i = t.i; printf("unwanted copy\n"); }
  ~T() { printf ("DOWN\n"); down++; }
  operator int () { return i; }
};

int main ()
{
  int t;

  if (T t = 1)
    ;

  printf ("\n");
  
  int j = 3;
  while (T t = j--)
    ;
  
  printf ("\n");
  
  j = 3;
  while (1)
    {
      T t = j--;
      if (t) continue;
      break;
    }
  
  printf ("\n");
  
  j = 3;
  for (;T t = j--;)
    ;

  printf ("\n");
  
  for (int k = 3; T t = k--;)
    ;

  printf ("\n");
  
  switch (T t = 34)
    {
    case 34:
      ;
    }

  printf ("\n");
  
  if (up == down && up == 18)
    return 0;
  else
    return 1;
}