summaryrefslogtreecommitdiff
path: root/Test/test0/BadLabels1.bpl
blob: cbbe0f5eabd75174211eec47d9e2b94e63293132 (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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
// RUN: %boogie -noVerify %s > %t
// RUN: %diff %s.expect %t
procedure P0()
{
  // these labels don't exist at all
  goto X;  // error: undefined label
  goto Y;  // error: undefined label
}

procedure P1(y: int)
{
  goto X;  
  while (y < 100)
  {
    X:
  }

  Q:
  if (y == 102) {
    A:
    goto Q;
  } else if (y == 104) {
    B:
  } else {
    C:
    goto K;  
  }

  while (y < 1000)
  {
    K:
    goto A;  
    if (y mod 2 == 0) {
      goto L;
      M:
    }
    goto K, L;
    L:
    if (*) {
      goto M;  
    }
  }
  goto B;  
}


procedure Break(n: int)
{
  break;  // error: break not inside a loop
  if (*) {
    break;  // error: label-less break not inside a loop
  }
  
  A:
  if (*) {
    break A;  // this is fine, since the break statement uses a label
  }

  B:
  assert 2 <= n;
  while (*) {
    break B;  // error: B does not label a loop
    break;
    C: while (*) { assert n < 100; }
    break A;     // error: A does not label a loop
    break C;     // error: A does not label an enclosing loop
    F: break F;  // error: F does not label an enclosing loop
  }

  D:
  while (*) {
    E:
    while (*) {
      if (*) {
        break;
      } else if (*) {
        if (*) { break E; }
      } else {
        break D;
      }
    }
  }
}