Skip to content

Commit

Permalink
Avoid nelua_panic_cstring declaration with nochecks pragma
Browse files Browse the repository at this point in the history
  • Loading branch information
edubart committed Aug 4, 2024
1 parent b24ce01 commit 38c2d9c
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lualib/nelua/cbuiltins.lua
Original file line number Diff line number Diff line change
Expand Up @@ -660,11 +660,12 @@ function cbuiltins.nelua_idiv_(context, type, checked)
if context.usedbuiltins[name] then return name end
assert(type.is_signed)
local stype, utype = type:signed_type(), type:unsigned_type()
context:ensure_builtins('NELUA_UNLIKELY', 'nelua_panic_cstring')
context:ensure_builtins('NELUA_UNLIKELY')
local emitter = CEmitter(context)
emitter:add_ln('{') emitter:inc_indent()
emitter:add_indent_ln('if(NELUA_UNLIKELY(b == -1)) return 0U - (', utype ,')a;')
if checked then
context:ensure_builtins('nelua_panic_cstring')
emitter:add_indent_ln('if(NELUA_UNLIKELY(b == 0)) nelua_panic_cstring("division by zero");')
end
emitter:add_indent_ln(stype,' q = a / b;')
Expand All @@ -680,11 +681,12 @@ function cbuiltins.nelua_imod_(context, type, checked)
local name = (checked and 'nelua_assert_imod_' or 'nelua_imod_')..type.codename
if context.usedbuiltins[name] then return name end
assert(type.is_signed)
context:ensure_builtins('NELUA_UNLIKELY', 'nelua_panic_cstring')
context:ensure_builtins('NELUA_UNLIKELY')
local emitter = CEmitter(context)
emitter:add_ln('{') emitter:inc_indent()
emitter:add_indent_ln('if(NELUA_UNLIKELY(b == -1)) return 0;')
if checked then
context:ensure_builtins('nelua_panic_cstring')
emitter:add_indent_ln('if(NELUA_UNLIKELY(b == 0)) nelua_panic_cstring("division by zero");')
end
emitter:add_indent_ln(type,' r = a % b;')
Expand Down

0 comments on commit 38c2d9c

Please sign in to comment.