From: Jerry DeLisle Date: Sun, 6 Jan 2008 18:19:06 +0000 (+0000) Subject: re PR fortran/34387 (FAIL: gfortran.dg/optional_dim_2.f90: FE vs library argument... X-Git-Tag: releases/gcc-4.3.0~728 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9b09c4dec4d39938f5b85e20364fd4697fafc91c;p=thirdparty%2Fgcc.git re PR fortran/34387 (FAIL: gfortran.dg/optional_dim_2.f90: FE vs library argument missmatch) 2008-01-06 Jerry DeLisle PR fortran/34387 * trans-expr.c (gfc_conv_missing_dummy): Use a temporary to type convert the dummy variable expression, test for NULL, and pass the variable address to the called function. From-SVN: r131356 --- diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index f7b85b067311..932527eadf8f 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,10 @@ +2008-01-06 Jerry DeLisle + + PR fortran/34387 + * trans-expr.c (gfc_conv_missing_dummy): Use a temporary to type convert + the dummy variable expression, test for NULL, and pass the variable + address to the called function. + 2007-01-06 Tobias Burnus PR fortran/34658 diff --git a/gcc/fortran/trans-expr.c b/gcc/fortran/trans-expr.c index 53cd7e644503..65c65e35233a 100644 --- a/gcc/fortran/trans-expr.c +++ b/gcc/fortran/trans-expr.c @@ -154,18 +154,24 @@ gfc_conv_missing_dummy (gfc_se * se, gfc_expr * arg, gfc_typespec ts, int kind) present = gfc_conv_expr_present (arg->symtree->n.sym); - tmp = build3 (COND_EXPR, TREE_TYPE (se->expr), present, se->expr, - fold_convert (TREE_TYPE (se->expr), integer_zero_node)); - tmp = gfc_evaluate_now (tmp, &se->pre); - if (kind > 0) { + /* Create a temporary and convert it to the correct type. */ tmp = gfc_get_int_type (kind); - tmp = fold_convert (tmp, se->expr); - tmp = gfc_evaluate_now (tmp, &se->pre); + tmp = fold_convert (tmp, build_fold_indirect_ref (se->expr)); + + /* Test for a NULL value. */ + tmp = build3 (COND_EXPR, TREE_TYPE (tmp), present, tmp, integer_one_node); + tmp = gfc_evaluate_now (tmp, &se->pre); + se->expr = build_fold_addr_expr (tmp); + } + else + { + tmp = build3 (COND_EXPR, TREE_TYPE (se->expr), present, se->expr, + fold_convert (TREE_TYPE (se->expr), integer_zero_node)); + tmp = gfc_evaluate_now (tmp, &se->pre); + se->expr = tmp; } - - se->expr = tmp; if (ts.type == BT_CHARACTER) {