-
Notifications
You must be signed in to change notification settings - Fork 205
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes for typing arithmetic on address space pointers.
- Loading branch information
1 parent
d824ce7
commit c0c750a
Showing
2 changed files
with
29 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
-- Tests of pointers with address spaces. | ||
|
||
-- The exact meaning of this depends on the target, but at least basic | ||
-- code compilation should work. | ||
|
||
local function ptr1(ty) | ||
-- A pointer in address space 1. | ||
return terralib.types.pointer(ty, 1) | ||
end | ||
|
||
terra test(x : &int, y : ptr1(int)) | ||
-- Should be able to do math on pointers with non-zero address spaces: | ||
var a = [ptr1(int8)](y) | ||
var b = a + 8 | ||
var c = [ptr1(int)](b) | ||
var d = c - y | ||
y = c | ||
|
||
-- Casts should work: | ||
y = [ptr1(int)](x) | ||
x = [&int](y) | ||
|
||
return d | ||
end | ||
test:compile() | ||
print(test) |