summaryrefslogtreecommitdiff
path: root/tnslc/simple.tnsl
blob: c0c1821c8e12d52163c33bd78bebad7dca5a6b57 (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
# testing file to try to reproduce bugs as best as possible

# 8x4 bytes
struct AddressError {
    uint a, b, c, d
}

/; method AddressError
    /; if_check [bool]
        /; if (self.a < 0 && self.b !< self.d / 4)
            return true
        ;; else if (self.c == 0)
            return false
        ;/
        return self.d != 1
    ;/
;/

/; main (int argc, ~~uint argv) [int]
    # On windows, the first two arguments are passed in RCX and RDX, so we need to
    # update their positions here or else tnsl will have garbage values in r8 and r9
    asm "mov r8, rcx"
    asm "mov r9, rdx"

    AddressError ae
    ae.a = ae.b = ae.c = ae.d = 0

    /; if (ae.if_check())
        return 1
    ;/
    
    return 0
;/