Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix error in cglobal expressions created by macro with escaped literals #26504

Merged
merged 2 commits into from
Mar 20, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/ccalltest.c
Original file line number Diff line number Diff line change
Expand Up @@ -978,3 +978,6 @@ JL_DLLEXPORT int threadcall_args(int a, int b) {
JL_DLLEXPORT void c_exit_finalizer(void* v) {
printf("c_exit_finalizer: %d, %u", *(int*)v, (unsigned)((uintptr_t)v & (uintptr_t)1));
}

// global variable for cglobal testing
JL_DLLEXPORT const int global_var = 1;
2 changes: 1 addition & 1 deletion src/macroexpand.scm
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@
m parent-scope inarg))

(define (resolve-expansion-vars- e env m parent-scope inarg)
(cond ((or (eq? e 'true) (eq? e 'false) (eq? e 'end) (eq? e 'ccall))
(cond ((or (eq? e 'true) (eq? e 'false) (eq? e 'end) (eq? e 'ccall) (eq? e 'cglobal))
e)
((symbol? e)
(let ((a (assq e env)))
Expand Down
9 changes: 9 additions & 0 deletions test/ccall.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1316,3 +1316,12 @@ function caller22734(ptr)
ccall(ptr, Float64, (Ref{Abstract22734},), obj)
end
@test caller22734(ptr22734) === 32.0

# 26297#issuecomment-371165725
# test that the first argument to cglobal is recognized as a tuple literal even through
# macro expansion
macro cglobal26297(sym)
:(cglobal(($(esc(sym)), libccalltest), Cint))
end
cglobal26297() = @cglobal26297(:global_var)
@test cglobal26297() != C_NULL