forked from AbleOS/holey-bytes
making sure sliced pointer is loaded
Signed-off-by: Jakub Doka <jakub.doka2@gmail.com>
This commit is contained in:
parent
9f67b22aa2
commit
5909837015
|
@ -798,6 +798,16 @@ main := fn(): uint {
|
|||
|
||||
### Purely Testing Examples
|
||||
|
||||
#### slice_to_global_pointer
|
||||
```hb
|
||||
a := @as(^u8, @bitcast(0))
|
||||
|
||||
main := fn(): ^u8 {
|
||||
b := a[0..100]
|
||||
return b.ptr
|
||||
}
|
||||
```
|
||||
|
||||
#### subsclice_bug
|
||||
```hb
|
||||
main := fn(): void {
|
||||
|
|
|
@ -1268,7 +1268,7 @@ impl<'a> Codegen<'a> {
|
|||
}
|
||||
}
|
||||
Expr::Index { base, index: &Expr::Range { start, end, pos } } => {
|
||||
let bs = self.ptr_expr(base)?;
|
||||
let mut bs = self.ptr_expr(base)?;
|
||||
|
||||
let start = match start {
|
||||
Some(s) => self.checked_expr(s, ty::Id::UINT, "range start")?.id,
|
||||
|
@ -1325,7 +1325,10 @@ impl<'a> Codegen<'a> {
|
|||
let base = self.tys.make_ptr(elem);
|
||||
Value::new(self.load_mem(off, base)).ty(base)
|
||||
}
|
||||
ty::Kind::Ptr(_) => bs,
|
||||
ty::Kind::Ptr(_) => {
|
||||
self.strip_ptr(&mut bs);
|
||||
bs
|
||||
}
|
||||
_ => unreachable!(),
|
||||
};
|
||||
ptr.id = self.offset_ptr(ptr.id, elem, start).id;
|
||||
|
@ -4462,6 +4465,7 @@ mod tests {
|
|||
fb_driver;
|
||||
|
||||
// Purely Testing Examples;
|
||||
slice_to_global_pointer;
|
||||
subsclice_bug;
|
||||
string_array;
|
||||
proper_ident_propagation;
|
||||
|
|
8
lang/tests/son_tests_slice_to_global_pointer.txt
Normal file
8
lang/tests/son_tests_slice_to_global_pointer.txt
Normal file
|
@ -0,0 +1,8 @@
|
|||
main:
|
||||
LRA r13, r0, :a
|
||||
LD r13, r13, 0a, 8h
|
||||
CP r1, r13
|
||||
JALA r0, r31, 0a
|
||||
code size: 50
|
||||
ret: 0
|
||||
status: Ok(())
|
Loading…
Reference in a new issue