-- version control marker $Id: cgtest09.occ,v 1.5 1996/11/28 11:19:28 svd Exp $
-- Array handling

PROC cgtest9 (CHAN OF BYTE keyb, scr, err)
  #INCLUDE "cgmain.occ"

  SEQ
    init ("CG test 9", "Array handling")

    --{{{  integer array handling          (A000 - A005)
    --{{{  output message
    title ("Integer arrays")
    --}}}
    [10] INT a :
    INT x, y :
    SEQ
      SEQ i = 0 FOR 10
        a[i] := i
      check (a[0], 0, "A001")
      check (a[5], 5, "A002")
      check (a[9], 9, "A003")
      x := 4
      check (a[x], 4, "A004")
      z IS x :
      check (a[z], 4, "A005")
    --}}}
    --{{{  abbreviated arrays              (A100 - A110)
    --{{{  output message
    title ("Abbreviated arrays")
    --}}}
    --{{{  A100 to A103
    [10] INT a :
    #PRAGMA PERMITALIASES a
    z IS a :
    INT x :
    SEQ
      SEQ i = 0 FOR 10
        a [i] := i
      SEQ i = 0 FOR 10
        IF
          a [i] = z [i]
            check (i, i, "A100")
          TRUE
            check (-1, i, "A101")
      x := 4
      check (z[x], a[x], "A102")
      check (z[x], 4,    "A103")
    --}}}
    --{{{  A110
    VAL test IS ["hello","every","blurb"] :
    [3] [5] BYTE a :
    #PRAGMA PERMITALIASES a
    b IS a [2] :
    SEQ
      a := test
      SEQ i = 0 FOR 5
        check (INT b [i], INT "blurb" [i], "A110")
    --}}}
    --}}}
    --{{{  nested arrays                   (A200 - A204)
    --{{{  output message
    title ("Nested arrays")
    --}}}
    [10] INT a :
    INT x, y :
    SEQ
      a [0] := 0
      SEQ i = 1 FOR 9
        a [ a[i-1] + 1] := i
      check (a[5], 5, "A201")
      check (a[a[a[a[a[a[5]]]]]], 5, "A202")
      check (a[ a[ a[ a[ a[ a[ a[ a[ a[9]-1 ]-1 ]-1 ]-1 ]-1 ]-1 ]-1 ]-1 ], 1,
             "A203")
      x := 0
      SEQ i = 0 FOR 10
        SEQ
          y := i
          x := x + a[y]
      check (x, 45, "A204")
    --}}}
    --{{{  non integer arrays              (A300 - A309)
    --{{{  output message
    title ("Other array types")
    --}}}
    [10] BOOL b :
    [10] BYTE c :
    BOOL x, x2 :
    BYTE y :
    SEQ
      b [0] := TRUE
      c [0] := 'a'
      SEQ i = 1 FOR 9
        SEQ
          b [i] := NOT (b [i-1])
          c [i] := BYTE ('a' (INT) + i)
      check (INT b[0], INT TRUE, "A301")
      check (INT b[7], INT FALSE, "A302")
      check (INT b[8], INT TRUE,  "A303")
      check (INT c[0], 'a' (INT), "A304")
      check (INT c[1], 'b' (INT), "A305")
      check (INT c[6], 'g' (INT), "A306")
      x := TRUE
      SEQ i = 0 FOR 10
        IF
          c [i] = ( BYTE ('a' (INT) + i) )
            SKIP
          TRUE
            x := FALSE
      check (INT x, INT TRUE, "A307")
      x := TRUE
      x2 := FALSE
      SEQ i = 0 FOR 5
        SEQ
          x := x AND b [i*2]
          x2 := x2 OR b [(i*2) + 1]
      check (INT x, INT TRUE, "A308")
      check (INT x2, INT FALSE, "A309")
    --}}}
    --{{{  channel arrays                  (A400 - A402)
    --{{{  output message
    title ("Channel arrays")
    --}}}
    [5] CHAN OF INT c :
    [5] INT a :
    INT x :
    SEQ
      PAR
        PAR i = 0 FOR 5
          c [i] ! i
        PAR i = 0 FOR 5
          c [i] ? a [4 - i]
      SEQ i = 0 FOR 5
        check (a[i], 4 - i, "A401")
      x := 3
      PAR
        c [3] ! 42
        c [x] ? a [x]
      check (a[3], 42, "A402")
    
    --}}}
    --{{{  multi dimensional arrays        (A500 - A599)
    --{{{  output message
    title ("Multi dimensional arrays")
    --}}}
    [5] [6] INT a :
    SEQ
      VAL b IS [100,66,22,88,345,76] :
      SEQ
        --{{{  test using constants        (A501 - A509)
        SEQ i = 0 FOR 5
          SEQ j = 0 FOR 6
            a [i] [j] := i + j
        check (a[0][0], 0, "A501")
        check (a[0][3], 3, "A502")
        check (a[3][0], 3, "A503")
        check (a[4][4], 8, "A504")
        check (a[4][5], 9, "A505")
        a[3] := b
        check (a[3][0], 100, "A506")
        check (a[3][5],  76, "A507")
        check (a[2][5],   7, "A508")
        check (a[4][3],   7, "A509")
        --}}}
        --{{{  test using VALS             (A511 - A519)
        VAL zero  IS 0 :
        VAL two   IS 2 :
        VAL three IS 3 :
        VAL four  IS 4 :
        VAL five  IS 5 :
        SEQ
          SEQ i = zero FOR five
            SEQ j = zero FOR 6
              a [i] [j] := i + j
          check (a[zero][zero],   zero, "A511")
          check (a[zero][three], three, "A512")
          check (a[three][zero], three, "A513")
          check (a[four][four],      8, "A514")
          check (a[four][five],      9, "A515")
          a[three] := b
          check (a[three][zero], 100, "A516")
          check (a[three][five],  76, "A517")
          check (a[two][five],     7, "A518")
          check (a[four][three],   7, "A519")
        --}}}
        --{{{  test using variables        (A521 - A529)
        INT zero, two, three, four, five :
        SEQ
          zero  := 0
          two   := 2
          three := 3
          four  := 4
          five  := 5
          SEQ i = zero FOR five
            SEQ j = zero FOR 6
              a [i] [j] := i + j
          check (a[zero][zero],   zero, "A521")
          check (a[zero][three], three, "A522")
          check (a[three][zero], three, "A523")
          check (a[four][four],      8, "A524")
          check (a[four][five],      9, "A525")
          a[three] := b
          check (a[three][zero], 100, "A526")
          check (a[three][five],  76, "A527")
          check (a[two][five],     7, "A528")
          check (a[four][three],   7, "A529")
        --}}}
      --{{{  test a bug fix                (A531)
      PROC p ([10]INT x)
        check (x[2], 2, "A531")
      :
      [10][10]INT x :
      SEQ
        SEQ i = 0 FOR 10
          SEQ j = 0 FOR 10
            x [i][j] := i
        p (x [2])
      --}}}
      --{{{  ten dimensions                (A540 - A549)
      VAL size IS 2 :
      [1][2][size][size][size][size][size][size][size][size]INT a :
      [2][size][size][size][size][size][size][size][size]INT b :
      [size][size][size][size][size][size][size][size]INT c :
      [size][size][size][size][size][size][size]INT d :
      INT zero, one, two :
      SEQ
        zero  := 0
        one   := 1
        two   := 2
        --{{{  initialise a to the sum of its subscripts
        SEQ i1 = 0 FOR SIZE a
          a1 IS a [i1] :
          SEQ i2 = 0 FOR SIZE a1
            a2 IS a1 [i2] :
            SEQ i3 = 0 FOR SIZE a2
              a3 IS a2 [i3] :
              SEQ i4 = 0 FOR SIZE a3
                a4 IS a3 [i4] :
                SEQ i5 = 0 FOR SIZE a4
                  a5 IS a4 [i5] :
                  SEQ i6 = 0 FOR SIZE a5
                    a6 IS a5 [i6] :
                    SEQ i7 = 0 FOR SIZE a6
                      a7 IS a6 [i7] :
                      SEQ i8 = 0 FOR SIZE a7
                        a8 IS a7 [i8] :
                        SEQ i9 = 0 FOR SIZE a8
                          a9 IS a8 [i9] :
                          SEQ i10 = 0 FOR SIZE a9
                            --a [i1][i2][i3][i4][i5][i6][i7][i8][i9][i10] :=
                            a9 [i10] := i1+(i2+(i3+(i4+(i5+(i6+(i7+(i8+(i9+i10))))))))
        --}}}
        check (a[zero][zero][one][one][one][one][one][one][one][one],
               8, "A540")
        b := a[zero * one]
        c := b[two - one]
        d := c[one + zero]
        check (d[one][one][one][one][one][one][one], 9, "A541")
        --{{{  same check with a bit of subscript calculation
        check (d[one * ((two / two) + (one - one))][one *
                       ((two / two) + (one - one))][one *
                       ((two / two) + (one - one))][one *
                       ((two / two) + (one - one))][one *
                       ((two / two) + (one - one))][one *
                       ((two / two) + (one - one))][one *
                       ((two / two) + (one - one))],        9, "A542")
        --}}}
      --}}}
      --{{{  stuff from martin             (A550 - A559)
      [10] [20] INT a :
      INT i, j, k, l :
      SEQ
        --{{{  initialise a [i] [j] to i + j
        SEQ i = 0 FOR SIZE a
          b IS a [i] :
          SEQ j = 0 FOR SIZE b
            b [j] := i + j
        --}}}
        --{{{  test generation of address of base of array  (A550)
        INT count :
        --{{{  declarations of q, r, s
        PROC q ([] [] INT x)
          count := count + x [1] [1]
        :
        PROC r ([] INT x)
          count := count + x [1]
        :
        PROC s (INT x)
          count := count + x
        :
        --}}}
        SEQ
          count := 0
          i := 1
          j := 2
          q (a)                     -- should add 2
          r (a [0])                 -- should add 1
          r (a [2])                 -- 3
          r (a [j])                 -- 3
          r (a [j + 2])             -- 5
          s (a [0] [0])             -- 0
          s (a [i] [j])             -- 3
          s (a [i + 2] [j + 3])     -- 8
          check (count, 25, "A550")
        --}}}
        --{{{  test subscript folding and checking          (A555 - A559)
        j := 2
        k := 3
        --{{{  a [0] [...                                   (A555)
        i := a [0] [0]
        i := a [0] [2] + i
        i := a [0] [j] + i
        i := a [0] [j + 2] + i
        check (i, 8, "A555")
        --}}}
        --{{{  a [2] [...                                   (A556)
        i := a [2] [0]
        i := a [2] [2] + i
        i := a [2] [j] + i
        i := a [2] [j + 2] + i
        check (i, 16, "A556")
        --}}}
        --{{{  a [k] [...                                   (A557)
        i := a [k] [0]
        i := a [k] [2] + i
        i := a [k] [j] + i
        i := a [k] [j + 2] + i
        check (i, 20, "A557")
        --}}}
        --{{{  a [k + 2] [...                               (A558)
        i := a [k + 2] [0]
        i := a [k + 2] [2] + i
        i := a [k + 2] [j] + i
        i := a [k + 2] [j + 2]  + i
        check (i, 28, "A558")
        --}}}
        --}}}
      --}}}
      --{{{  complex offset calculation    (A560)
      PROC A560()
        VAL array IS [ [1, 2, 3], [4, 5, 6] ] :
        INT a, b, c :
        SEQ
          a, b, c := 0, 0, 0
          check(array[ a + (b + (c + 1))][ a + (b + (c + 1)) ], 5, "A560")
      :
      A560()
      --}}}
    
    --}}}
    --{{{  testing SIZE                    (A600 - A701)
    --{{{  output message
    title ("SIZE operator")
    --}}}
    --{{{  proc test.size (of an []INT array)
    PROC test.size (VAL []INT a, VAL INT size, VAL []BYTE string)
      check (SIZE a, size, string)
    :
    --}}}
    SEQ
      --{{{  integer tables
      VAL test IS [1,2,3,4,5] :
      VAL test2 IS [[1],[2],[3],[4],[5]] :
      VAL test3 IS [[1,2,3,4,5]] :
      SEQ
        check (SIZE test, 5, "A601")
        check (SIZE test2, 5, "A602")
        check (SIZE test3, 1, "A603")
        test.size (test, 5, "A604")
        test.size (test2 [3], 1, "A605")
        test.size (test3 [0], 5, "A606")
        VAL temp IS test3 [0] :
        SEQ
          check (SIZE temp, 5, "A607")
          test.size (temp, 5, "A608")
        VAL temp IS test2 [2] :
        SEQ
          check (SIZE temp, 1, "A609")
          test.size (temp, 1, "A610")
        check (SIZE [1,2,3,4,5,6,7,8,9], 9, "A611")
      --}}}
      --{{{  byte tables
      VAL array IS "hello" :
      VAL array2 IS ["hello","goodb"] :
      SEQ
        check (SIZE array, 5, "A620")
        check (SIZE array2, 2, "A621")
        check (SIZE array2[0], 5, "A622")
        check (SIZE array2[1], 5, "A623")
        check (SIZE "splurgle", 8, "A624")
      --}}}
      --{{{  integer arrays
      [10] INT a :
      #PRAGMA PERMITALIASES a
      b IS a :
      [15] [6] INT c :
      d IS c [4] :
      
      SEQ
        check (SIZE a, 10, "A631")
        check (SIZE b, 10, "A632")
        check (SIZE c, 15, "A633")
        check (SIZE d, 6, "A634")
        test.size (a, 10, "A635")
        test.size (b, 10, "A636")
        test.size (c[0], 6, "A637")
        test.size (d, 6, "A638")
      --}}}
      --{{{  byte arrays
      [5] BYTE a :
      #PRAGMA PERMITALIASES a
      [5] [3] BYTE b :
      #PRAGMA PERMITALIASES b
      c IS b :
      d IS a :
      e IS b [2] :
      SEQ
        check (SIZE a, 5, "A641")
        check (SIZE b, 5, "A642")
        check (SIZE c, 5, "A643")
        check (SIZE d, 5, "A644")
        check (SIZE e, 3, "A645")
        a := "howdy"
        check (SIZE a, 5, "A646")
        check (SIZE d, 5, "A647")
      --}}}
      --{{{  slices
      [100] INT a :
      INT x, y :
      SEQ
        check (SIZE ["hello" FROM 2 FOR 3], 3, "A651")
        check (SIZE ["hello" FROM 0 FOR 5], 5, "A652")
        check (SIZE [a FROM 0 FOR 10], 10, "A653")
        check (SIZE [a FROM 56 FOR 6], 6, "A654")
        x := 16
        y := 53
        check (SIZE [a FROM x FOR 64], 64, "A655")
        check (SIZE [a FROM x FOR y], 53, "A656")
        check (SIZE [a FROM 10 FOR y], 53, "A656")
        SEQ i = 1 FOR 10
          check (SIZE [a FROM x FOR i], i, "A657")
        SEQ i = 1 FOR 10
          SEQ
            y := i
            check (SIZE [a FROM x FOR y], i, "A658")
        y := 8
      --}}}
      --{{{  multi dimensional arrays
      [2] [3] [4] [5] [6] [7] INT a :
      INT i :
      SEQ
        --{{{  constant subscript
        check (SIZE a, 2, "A670")
        b IS a :
        check (SIZE b, 2, "A671")
        check (SIZE a [1], 3, "A672")
        b IS a [1] :
        check (SIZE b, 3, "A673")
        check (SIZE a [1] [2], 4, "A674")
        b IS a [1] [2] :
        check (SIZE b, 4, "A675")
        check (SIZE a [1] [2] [3], 5, "A676")
        b IS a [1] [2] [3] :
        check (SIZE b, 5, "A677")
        check (SIZE a [1] [2] [3] [4], 6, "A678")
        b IS a [1] [2] [3] [4] :
        check (SIZE b, 6, "A679")
        check (SIZE a [1] [2] [3] [4] [5], 7, "A680")
        b IS a [1] [2] [3] [4] [5] :
        check (SIZE b, 7, "A681")
        --}}}
        --{{{  variable subscript
        i := 1
        check (SIZE a, 2, "A690")
        b IS a :
        check (SIZE b, 2, "A691")
        check (SIZE a [i], 3, "A692")
        b IS a [i] :
        check (SIZE b, 3, "A693")
        check (SIZE a [i] [2], 4, "A694")
        b IS a [i] [2] :
        check (SIZE b, 4, "A695")
        check (SIZE a [i] [2] [3], 5, "A696")
        b IS a [i] [2] [3] :
        check (SIZE b, 5, "A697")
        check (SIZE a [i] [2] [3] [4], 6, "A698")
        b IS a [i] [2] [3] [4] :
        check (SIZE b, 6, "A699")
        check (SIZE a [i] [2] [3] [4] [5], 7, "A700")
        b IS a [i] [2] [3] [4] [5] :
        check (SIZE b, 7, "A701")
        --}}}
      --}}}
    --}}}
    --{{{  strings                         (A800 - A899)
    --{{{  output message
    title ("String handling")
    --}}}
    --{{{  check subscript access          (A800 - A819)
    INT x , y :
    VAL z IS 3 :
    VAL word IS "antidisestablishmentarianism" :
    [7] BYTE message :
    #PRAGMA PERMITALIASES message
    message2 IS message :
    SEQ
      check (INT "help" [2], INT 'l', "A800")
      check (INT word [2], INT 't', "A801")
      check (INT "help" [z], INT 'p', "A802")
      check (INT word [z], INT 'i', "A803")
      x := 2
      check (INT "help" [x], INT 'l', "A804")
      check (INT word [x], INT 't', "A805")
      message := "blurble"
      check (INT message [3], INT 'r', "A806")
      check (INT message2 [3], INT 'r', "A807")
      check (INT message [z], INT 'r', "A808")
      check (INT message2 [z], INT 'r', "A809")
      check (INT message [x], INT 'u', "A810")
      check (INT message2 [x], INT 'u', "A811")
    --}}}
    #IF NOT DEFINED (COMPILER.TOCK)
    -- The *l escape is not in the language spec.
    --{{{  check "*l"                      (A820 - A839)
    VAL test.null IS "*l" :
    VAL test.one  IS "*l1" :
    VAL test.two  IS "*l12" :
    VAL test.ten  IS "*l1234567890" :
    VAL test.cap  IS "*L" :
    [SIZE test.ten] BYTE new.ten :
    SEQ
      check (SIZE test.null,     1, "A820")
      check (INT  test.null [0], 0, "A821")
      check (SIZE test.one,      2, "A822")
      check (INT  test.one [0],  1, "A823")
      check (SIZE test.two,      3, "A824")
      check (INT  test.two [0],  2, "A825")
      check (SIZE test.ten,     11, "A826")
      check (INT  test.ten [0], 10, "A827")
      check (SIZE test.cap,      1, "A828")
      check (INT  test.cap [0],  0, "A829")
    
      check (INT (test.one [INT test.one [0]]), INT '1', "A830")
      check (INT (test.two [INT test.two [0]]), INT '2', "A831")
      check (INT (test.ten [INT test.ten [0]]), INT '0', "A832")
    
      new.ten := test.ten
      check (SIZE new.ten,     11, "A835")
      check (INT  new.ten [0], 10, "A836")
      check (INT (new.ten  [INT new.ten  [0]]), INT '0', "A837")
    --}}}
    #ENDIF
    --}}}
    --{{{  unused arrays
    PROC unused.arrays(VAL INT j)
      [10]INT unused.array :
      [10]INT used.array :
      SEQ
        SEQ i = 0 FOR SIZE used.array
          used.array[i] := i
        check(used.array[j], 7, "A900")
    :
    unused.arrays(7)
    --}}}
    --{{{  Bug 285
    PROC bug.285()
      PROC p ([][4]BYTE bb)
        []BYTE c RETYPES bb :  -- this should check the size of c
        INT x :
        SEQ
          x := 1
          c[1] := 'a'
          x := INT c[x]
          check (x, INT 'a', "B285a")
      :
      [2][4]BYTE bb :
      p (bb)
    :
    bug.285()
    --}}}
    --{{{  Bug 570
    PROC bug.570()
      SEQ
        [10][4]REAL32 r, s :
        PLACE s IN WORKSPACE :
        REAL32 w :
        INT i :
        SEQ
          w := 88.0(REAL32)
          SEQ j = 0 FOR SIZE r
            SEQ k = 0 FOR SIZE r[0]
              r[j][k] := REAL32 ROUND (j + k)
          s := r
          i := 5
          w := r[i][3]
          check(INT ROUND w, 8, "B570a")
          w := s[i][3]
          check(INT ROUND w, 8, "B570b")
          z IS r[i][3] :
          w := z
          check(INT ROUND w, 8, "B570c")
          z IS s[i][3] :
          w := z
          check(INT ROUND w, 8, "B570d")
          VAL z IS r[i][3] :
          w := z
          check(INT ROUND w, 8, "B570e")
          VAL z IS s[i][3] :
          w := z
          check(INT ROUND w, 8, "B570f")
        [10][4]REAL64 r, s :
        PLACE s IN WORKSPACE :
        REAL64 w :
        INT i :
        SEQ
          w := 88.0(REAL64)
          SEQ j = 0 FOR SIZE r
            SEQ k = 0 FOR SIZE r[0]
              r[j][k] := REAL64 ROUND (j + k)
          s := r
          i := 5
          w := r[i][3]
          check(INT ROUND w, 8, "B570g")
          w := s[i][3]
          check(INT ROUND w, 8, "B570h")
          z IS r[i][3] :
          w := z
          check(INT ROUND w, 8, "B570i")
          z IS s[i][3] :
          w := z
          check(INT ROUND w, 8, "B570j")
          VAL z IS r[i][3] :
          w := z
          check(INT ROUND w, 8, "B570k")
          VAL z IS s[i][3] :
          w := z
          check(INT ROUND w, 8, "B570l")
    :
    bug.570()
    --}}}
    --{{{  Bug 1404 / 149
    PROC bug.1404.149()
      VAL n IS 10 :
      [n]BYTE line2 :
      PROC p ([][]BYTE buffer)
        PROC q ()
          VAL line IS buffer[0] :
          line2 := line
        :
        q()
      :
      [5][n]BYTE buffer :
      SEQ
        SEQ i = 0 FOR SIZE buffer
          SEQ j = 0 FOR n
            SEQ
              buffer[i][j] := BYTE (i + j)
              line2 [j]    := BYTE 99
        p(buffer)
        SEQ j = 0 FOR n
          check(INT line2[j], j, "B1404a")
    :
    bug.1404.149()
    --}}}
    --{{{  Bug xxx
    PROC bug.xxx ()
      SEQ
        [10]INT a :
        PLACE a IN VECSPACE :
        SEQ
          SEQ i = 0 FOR SIZE a
            a[i] := i
          b IS [a FROM 4 FOR 6] :
          b[3] := 88
          check(a[7], 88, "BxxxA")
    :
    bug.xxx()
    --}}}
    --{{{  bug 1682
    PROC bug.1682()
      PROC check.bug.1682(VAL [3]INT16 big)
        SEQ
          check(INT big[0],  99, "B1682a")
          check(INT big[1], -99, "B1682b")
          check(INT big[2],   2, "B1682c")
      :
      INT16 var1, var2 :
      SEQ
        var1, var2 := 99(INT16), -99(INT16)
        [3]INT16 big :
        SEQ
          big := [0(INT16), 1(INT16), 2(INT16)]
          [big FROM 0 FOR 2] := [INT16 var1, INT16 var2]
          check.bug.1682(big)
        [3]INT16 big :
        PLACE big IN WORKSPACE :
        SEQ
          big := [0(INT16), 1(INT16), 2(INT16)]
          [big FROM 0 FOR 2] := [INT16 var1, INT16 var2]
          check.bug.1682(big)
    :
    bug.1682()
    --}}}
    --{{{  bug 1782
    PROC bug.1782()
      [2]INT to.i :
      SEQ
        to.i := [111, -222]
    
        to.i.fs IS [to.i FROM 1 FOR 0] :
        in.i.dp IS [to.i.fs FROM 0 FOR 0] :
        SEQ
          in.i.dp := in.i.dp
    
        check(to.i[0],  111, "B1782a")
        check(to.i[1], -222, "B1782b")
    :
    bug.1782()
    --}}}
    #IF FALSE
    --{{{  bug TS/2035
    PROC bug.TS.2035()
      INT in.addr, out.addr :
      PROC q ([]CHAN OF INT in, out)
        INT i, x :
        INT in0.addr, out0.addr :
        SEQ
          check(SIZE in, SIZE out, "B2035a")
          i := (SIZE in) - 1
          in[i]  ? x
          out[i] ! x
          LOAD.INPUT.CHANNEL (in0.addr,  in [0])
          LOAD.OUTPUT.CHANNEL(out0.addr, out[0])
          check(in0.addr,  in.addr,  "B2035b")
          check(out0.addr, out.addr, "B2035c")
      :
      PROC p(CHAN OF INT in, out)
        q([in], [out])
      :
      CHAN OF INT a, b :
      PAR
        INT x :
        SEQ
          a ! 99
          b ? x
        SEQ
          LOAD.INPUT.CHANNEL (in.addr,  a)
          LOAD.OUTPUT.CHANNEL(out.addr, b)
          p(a, b)
    :
    bug.TS.2035()
    --}}}
    #ENDIF
    --{{{  bug TS/2076
    PROC bug.TS.2076()
      PROTOCOL protocol
        CASE
          tag
      :
      [1]CHAN OF protocol c :
      PAR
        c[0] ! tag
        INT index :
        SEQ
          index := 0
          c[index] ? CASE tag
          check(index, 0, "B2076a")
    :
    bug.TS.2076()
    --}}}
    --{{{  bug INSdi01141
    PROC bug.INSdi01141()
      INT INLINE FUNCTION f() IS 27 :
      VAL c IS [f()] :
      [1]INT a :
      SEQ
        check(f(),  27, "di01141a")
        check(c[0], 27, "di01141b")
        a := c
        check(a[0], 27, "di01141c")
    :
    bug.INSdi01141()
    --}}}
    --{{{  multiple subscripts
    PROC multiple.subscripts()
      PROC local(VAL [3][5][7]INT x, VAL INT i, j, k, expected)
        SEQ
          check(x[i][j][k], expected, "MUL000")
          check(x[i][3][k], expected, "MUL001")
      :
      [3][5][7]INT x :
      SEQ
        SEQ i = 0 FOR SIZE x
          SEQ j = 0 FOR SIZE x[0]
            SEQ k = 0 FOR SIZE x[0][0]
              x[i][j][k] := (i + j) + k
        local(x, 1, 3, 2, x[1][3][2])
    :
    multiple.subscripts()
    --}}}
    finish ()
:
