# --no-check-assert
var opt_no_check_assert: OptionBool = new OptionBool("Disable the evaluation of explicit 'assert' and 'as' (dangerous)", "--no-check-assert")
+ # --no-check-autocast
+ var opt_no_check_autocast: OptionBool = new OptionBool("Disable implicit casts on unsafe expression usage (dangerous)", "--no-check-autocast")
+
# --no-check-other
var opt_no_check_other: OptionBool = new OptionBool("Disable implicit tests: unset attribute, null receiver (dangerous)", "--no-check-other")
do
super
self.option_context.add_option(self.opt_output, self.opt_no_cc, self.opt_hardening)
- self.option_context.add_option(self.opt_no_check_covariance, self.opt_no_check_initialization, self.opt_no_check_assert, self.opt_no_check_other)
+ self.option_context.add_option(self.opt_no_check_covariance, self.opt_no_check_initialization, self.opt_no_check_assert, self.opt_no_check_autocast, self.opt_no_check_other)
end
end
mtype = self.anchor(mtype)
res = self.autobox(res, mtype)
end
+ var implicit_cast_to = nexpr.implicit_cast_to
+ if implicit_cast_to != null and not self.compiler.modelbuilder.toolcontext.opt_no_check_autocast.value then
+ var castres = self.type_test(res, implicit_cast_to)
+ self.add("if (!{castres}) \{")
+ self.add_abort("Cast failed")
+ self.add("\}")
+ end
self.current_node = old
return res
end
do
if node == null then return
node.accept_rapid_type_vistor(self)
+ if node isa AExpr then
+ var implicit_cast_to = node.implicit_cast_to
+ if implicit_cast_to != null then self.add_cast_type(implicit_cast_to)
+ end
node.visit_all(self)
end
plot "$name.gnu"
}
-bench_nitg_options --hardening --no-check-covariance --no-check-initialization --no-check-assert --no-check-other
+bench_nitg_options --hardening --no-check-covariance --no-check-initialization --no-check-assert --no-check-autocast --no-check-other
function bench_nitg-e_options()
{
--no-check-covariance Disable type tests of covariant parameters (dangerous)
--no-check-initialization Disable isset tests at the end of constructors (dangerous)
--no-check-assert Disable the evaluation of explicit 'assert' and 'as' (dangerous)
+ --no-check-autocast Disable implicit casts on unsafe expression usage (dangerous)
--no-check-other Disable implicit tests: unset attribute, null receiver (dangerous)
--separate Use separate compilation
--no-inline-intern Do not inline call to intern methods