Skip to content

Commit 91de604

Browse files
committed
Add a test for an error message for bindc
1 parent 1ec6b21 commit 91de604

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

tests/errors/bindc_10e.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
from lpython import (i64, i16, CPtr, c_p_pointer, Pointer, sizeof, packed,
2+
dataclass, ccallable, ccall, i32)
3+
4+
@ccall
5+
def _lfortran_malloc(size: i32) -> CPtr:
6+
pass
7+
8+
9+
def alloc(buf_size:i64) -> CPtr:
10+
return _lfortran_malloc(i32(buf_size))
11+
12+
13+
@packed
14+
@dataclass
15+
class S:
16+
a: i16
17+
b: i64
18+
19+
20+
def main():
21+
p1: CPtr = alloc(sizeof(S))
22+
print(p1)
23+
p2: Pointer[S] = c_p_pointer(p1, S)
24+
p2.a = i16(5)
25+
p2.b = i64(4)
26+
print(p2.a, p2.b)
27+
assert p2.a == i16(5)
28+
assert p2.b == i64(4)
29+
30+
31+
main()

tests/tests.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1151,6 +1151,10 @@ asr = true
11511151
filename = "errors/bindc_04.py"
11521152
asr = true
11531153

1154+
[[test]]
1155+
filename = "errors/bindc_10e.py"
1156+
asr = true
1157+
11541158
[[test]]
11551159
filename = "errors/cptr_01.py"
11561160
asr = true

0 commit comments

Comments
 (0)