From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20247 invoked by alias); 27 Jul 2008 13:52:50 -0000 Received: (qmail 19939 invoked by uid 48); 27 Jul 2008 13:52:05 -0000 Date: Sun, 27 Jul 2008 13:52:00 -0000 Message-ID: <20080727135205.19938.qmail@sourceware.org> X-Bugzilla-Reason: CC References: Subject: [Bug fortran/36403] [4.4 Regression] Some fortran tests using eoshift fail on SH In-Reply-To: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "burnus at gcc dot gnu dot org" Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2008-07/txt/msg02023.txt.bz2 ------- 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