Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6991154

Browse files
Check for argument size in the Sin and LogGamma intrinsics
1 parent 9c3f0cd commit 6991154

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/libasr/pass/intrinsic_function_registry.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -900,7 +900,9 @@ static inline ASR::asr_t* create_LogGamma(Allocator& al, const Location& loc,
900900
const std::function<void (const std::string &, const Location &)> err) {
901901
ASR::ttype_t *type = ASRUtils::expr_type(args[0]);
902902

903-
if (!ASRUtils::is_real(*type)) {
903+
if (args.n != 1) {
904+
err("Intrinsic `log_gamma` accepts exactly one argument", loc);
905+
} else if (!ASRUtils::is_real(*type)) {
904906
err("`x` argument of `log_gamma` must be real",
905907
args[0]->base.loc);
906908
}
@@ -951,7 +953,9 @@ namespace X {
951953
const std::function<void (const std::string &, const Location &)> err) \
952954
{ \
953955
ASR::ttype_t *type = ASRUtils::expr_type(args[0]); \
954-
if (!ASRUtils::is_real(*type) && !ASRUtils::is_complex(*type)) { \
956+
if (args.n != 1) { \
957+
err("Intrinsic `"#X"` accepts exactly one argument", loc); \
958+
} else if (!ASRUtils::is_real(*type) && !ASRUtils::is_complex(*type)) { \
955959
err("`x` argument of `"#X"` must be real or complex", \
956960
args[0]->base.loc); \
957961
} \
@@ -963,7 +967,6 @@ namespace X {
963967
const Location &loc, SymbolTable *scope, \
964968
Vec<ASR::ttype_t*>& arg_types, ASR::ttype_t *return_type, \
965969
Vec<ASR::call_arg_t>& new_args,int64_t overload_id) { \
966-
LCOMPILERS_ASSERT(arg_types.size() == 1); \
967970
ASR::ttype_t* arg_type = arg_types[0]; \
968971
return UnaryIntrinsicFunction::instantiate_functions(al, loc, scope, \
969972
#lcompilers_name, arg_type, return_type, new_args, overload_id); \

0 commit comments

Comments
 (0)