------- Comment #2 from burnus at gcc dot gnu dot org 2009-10-29 22:52 ------- Preliminary patch. The for the second part of the patch one needs still to update the comment. (Currently regtesting, so far no failure.)
... Actually, I think the block (second part) can also go away for fsym == NULL. In all cases, one has tmp = (a == NULL) ? a : NULL; which is really a noop. I fail to see how one can get anything else. One needs such a check for for absent arguments, but that is already handled in interface.c (or somewhere around that place) - and it is a compile-time replacement. Index: trans-expr.c =================================================================== --- trans-expr.c (Revision 153727) +++ trans-expr.c @@ -2943,6 +2943,12 @@ gfc_conv_procedure_call (gfc_se * se, gf tmp = build_fold_indirect_ref_loc (input_location, parmse.expr); tmp = gfc_trans_dealloc_allocated (tmp); + if (fsym->attr.optional + && e->expr_type == EXPR_VARIABLE + && e->symtree->n.sym->attr.optional) + tmp = fold_build3 (COND_EXPR, void_type_node, + gfc_conv_expr_present (e->symtree->n.sym), + tmp, build_empty_stmt (input_location)); gfc_add_expr_to_block (&se->pre, tmp); } @@ -2954,7 +2960,7 @@ gfc_conv_procedure_call (gfc_se * se, gf an intrinsic subroutine, however, fsym is NULL, but we might still have an optional argument, so we proceed to the substitution just in case. */ - if (e && (fsym == NULL || fsym->attr.optional)) + if (e && fsym == NULL) { /* If an optional argument is itself an optional dummy argument, check its presence and substitute a null if absent. */ -- burnus at gcc dot gnu dot org changed: What |Removed |Added ---------------------------------------------------------------------------- AssignedTo|unassigned at gcc dot gnu |burnus at gcc dot gnu dot |dot org |org Status|UNCONFIRMED |ASSIGNED Ever Confirmed|0 |1 Last reconfirmed|0000-00-00 00:00:00 |2009-10-29 22:52:37 date| | http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41850