Skip to content

Commit

Permalink
Fix spurious internal error on call to IDATE.
Browse files Browse the repository at this point in the history
Upstream code in routine ref_pd_subr in file semfunc.c changes
a call to the IDATE intrinsic into a user routine call if the
number or type of call arguments are invalid for the intrinsic.
The assert in routine rewrite_func_ast that is triggered due
to a missing definition of nargs is therefore unnecessary,
since the code is only reached when the call arguments have
already been validated.  Deleting the code with the asserts
leaves code for IDATE that is similar to nearby cases for other
intrinsics.
  • Loading branch information
tskeith committed Jan 24, 2018
1 parent a972bbd commit 31725c6
Showing 1 changed file with 2 additions and 17 deletions.
19 changes: 2 additions & 17 deletions tools/flang1/flang1exe/func.c
Expand Up @@ -2658,24 +2658,9 @@ rewrite_func_ast(int func_ast, int func_args, int lhs)
rtlRtn = DTY(A_DTYPEG(arg1)) == TY_CHAR ? RTE_date : RTE_datew;
goto sub_common;
case I_IDATE:
{
TY_KIND arg_ty = TY_NONE; /* args must all be short or int */
for (i = 0; i < nargs; ++i) {
int arg_ast = ARGT_ARG(func_args, i);
TY_KIND ty = DTY(A_DTYPEG(arg_ast));
if (i == 0) {
arg_ty = ty;
} else {
assert(arg_ty == ty,
"rewrite_func_ast:idate called with bad arguments", 0,
ERR_Fatal);
}
}
assert(arg_ty == TY_SINT || arg_ty == TY_INT,
"rewrite_func_ast:idate called with bad arguments", 0, ERR_Fatal);
rtlRtn = arg_ty == TY_SINT ? RTE_idate : RTE_jdate;
}
is_icall = FALSE;
arg1 = ARGT_ARG(func_args, 0);
rtlRtn = DTY(A_DTYPEG(arg1)) == TY_SINT ? RTE_idate : RTE_jdate;
goto sub_common;
case I_LASTVAL:
rtlRtn = RTE_lastval;
Expand Down

0 comments on commit 31725c6

Please sign in to comment.