Skip to content

Commit

Permalink
deprecate &x in ccall. fixes #6080
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffBezanson committed Sep 1, 2017
1 parent bad1329 commit e564008
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ Language changes
* Variable bindings local to `while` loop bodies are now freshly allocated on each loop iteration,
matching the behavior of `for` loops.

* Prefix `&` for by-reference arguments to `ccall` has been deprecated in favor of
`Ref` argument types ([#6080]).

Breaking changes
----------------

Expand Down
7 changes: 7 additions & 0 deletions src/julia-syntax.scm
Original file line number Diff line number Diff line change
Expand Up @@ -3511,6 +3511,13 @@ f(x) = yt(x)
((call new foreigncall)
(let* ((args
(cond ((eq? (car e) 'foreigncall)
(for-each (lambda (a)
(if (and (length= a 2) (eq? (car a) '&))
(deprecation-message
(string "Syntax \"&argument\"" (linenode-string current-loc)
" is deprecated. Remove the \"&\" and use a \"Ref\" argument "
"type instead."))))
(list-tail e 6))
;; NOTE: 2nd to 5th arguments of ccall must be left in place
;; the 1st should be compiled if an atom.
(append (if (atom? (cadr e))
Expand Down
1 change: 0 additions & 1 deletion test/ccall.jl
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ let a
a = 2.84 + 5.2im

@test_throws MethodError ccall((:cptest, libccalltest), Ptr{Complex{Int}}, (Ptr{Complex{Int}},), a)
@test_throws MethodError ccall((:cptest, libccalltest), Ptr{Complex{Int}}, (Complex{Int},), &a)
end


Expand Down

0 comments on commit e564008

Please sign in to comment.