------- Comment #3 from burnus at gcc dot gnu dot org 2008-07-27 13:52 ------- > Isn't this maybe a general problem about optional string arguments? > Or is this really a eoshift-specific problem? I'm just thinking about a > general solution for this kind of problem if it isn't.
I think this might be a more general problem, but it is not trivially solvable. For external procedures, if the interface is available (as required for optional arguments), the length is also present if the actual argument is missing. For intrinsic functions there exists also a formal argument list, but for EOSHIFT's ARRAY/BOUNDARY argument it is ts.type == BT_REAL. (EOSHIFT allows numeric types [real, integer, complex] and the character types.) And as the actual argument is NULL, its type can also not be used to know that the string length has to be passed. I therefore think FX's solution of adding a gfc_conv_intrinsic_eoshift is OK. The alternative would be to add a specific function with BT_CHARACTER type to the generic function "EOSHIFT". I'm not sure how to do this best. For fixing it using gfc_conv_intrinsic_eoshift: a) Check other intrinsic functions, which take an optional argument which is of character type. b) At least for the test case, the following if matches in trans-intrinsics.c's fc_conv_intrinsic_function: if (expr->rank > 0 && !expr->inline_noncopying_intrinsic) { lib = gfc_is_intrinsic_libcall (expr); if (lib != 0) { if (lib == 1) se->ignore_optional = 1; gfc_conv_intrinsic_funcall (se, expr); return; } } Thus adding a "case GFC_ISYM_EOSHIFT:" in the switch block does not make sense. (I think boundary needs to be an array and thus the if above always matches.) c) I think the function should be called conv_intrinsic_eoshift w/o gfc_ as it is not exported. In conv_intrinsic_eoshift I think one can add as first line: if (expr->value.function.actual->expr->ts.type != BT_CHARACTER) { gfc_conv_intrinsic_funcall (se, expr); return; } Or one covers both cases in that function. (One can check the actual argument type here because the first argument, ARRAY, must be present and BOUNDARY has the same type as ARRAY.) -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36403