Skip to content

Commit

Permalink
Merge pull request #15788 from JuliaLang/yyc/noret
Browse files Browse the repository at this point in the history
Better doc and codegen for noreturn ccall
  • Loading branch information
yuyichao committed Apr 8, 2016
2 parents 481a05c + 6e86d8c commit e8a2dd2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
10 changes: 10 additions & 0 deletions doc/manual/calling-c-and-fortran-code.rst
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,9 @@ Julia type with the same name, prefixed by C. This can help for writing portable
+-----------------------------------+-----------------+----------------------+-----------------------------------+
| ``void`` | | | ``Void`` |
+-----------------------------------+-----------------+----------------------+-----------------------------------+
| ``void`` and | | | ``Union{}`` |
| ``[[noreturn]]`` or ``_Noreturn`` | | | |
+-----------------------------------+-----------------+----------------------+-----------------------------------+
| ``void*`` | | | ``Ptr{Void}`` |
+-----------------------------------+-----------------+----------------------+-----------------------------------+
| ``T*`` (where T represents an | | | ``Ref{T}`` |
Expand Down Expand Up @@ -473,6 +476,13 @@ C name Standard Julia Alias Julia Base Type
Julia's ``Char`` type is 32 bits, which is not the same as the wide character
type (``wchar_t`` or ``wint_t``) on all platforms.

.. warning::

A return type of ``Union{}`` means the function will not return
i.e. C++11 ``[[noreturn]]`` or C11 ``_Noreturn`` (e.g. ``jl_throw`` or
``longjmp``). Do not use this for function that returns
no value (``void``) but does return.

.. note::

For ``wchar_t*`` arguments, the Julia type should be ``Cwstring`` (if the C
Expand Down
4 changes: 4 additions & 0 deletions src/ccall.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1013,6 +1013,10 @@ static std::string generate_func_sig(
AttributeSet::get(jl_LLVMContext, i + 1, paramattrs[i]));
}
}
if (rt == jl_bottom_type)
attributes = attributes.addAttribute(jl_LLVMContext,
AttributeSet::FunctionIndex,
Attribute::NoReturn);
return "";
}

Expand Down

0 comments on commit e8a2dd2

Please sign in to comment.