Hi Steve,
Am 18.12.24 um 22:37 schrieb Steve Kargl:
So, it seems that this section of the patch
+ gfc_init_se (&asis_se, se);
+ gfc_conv_expr (&asis_se, asis);
+ gfc_add_block_to_block (&se->pre, &asis_se.pre);
+ tmp = fold_build3_loc (input_location, COND_EXPR, void_type_node,
+ asis_se.expr, then_branch, else_branch);
needs to be protected by some code that starts with
present = gfc_conv_expr_present (asis->symtree->n.sym);
I tried the following patch on top of yours:
diff --git a/gcc/fortran/trans-intrinsic.cc b/gcc/fortran/trans-intrinsic.cc
index 2370b6dad55..886f999f206 100644
--- a/gcc/fortran/trans-intrinsic.cc
+++ b/gcc/fortran/trans-intrinsic.cc
@@ -10220,6 +10220,16 @@ conv_isocbinding_function (gfc_se *se, gfc_expr
*expr)
gfc_init_se (&asis_se, se);
gfc_conv_expr (&asis_se, asis);
+ if (asis->expr_type == EXPR_VARIABLE
+ && asis->symtree->n.sym->attr.dummy
+ && asis->symtree->n.sym->attr.optional)
+ {
+ tree present = gfc_conv_expr_present (asis->symtree->n.sym);
+ asis_se.expr = build3_loc (input_location, COND_EXPR,
+ logical_type_node, present,
+ asis_se.expr,
+ build_int_cst
(logical_type_node, 0));
+ }
gfc_add_block_to_block (&se->pre, &asis_se.pre);
tmp = fold_build3_loc (input_location, COND_EXPR,
void_type_node,
asis_se.expr, then_branch, else_branch);
This does fix the case of optional dummy asis for me.
There is another case I found while playing which is rejected:
print *, f_c_string(c_char_"abc", asis)
I am not entirely sure if this is the right way to encode string
literals that are interoperable, but Intel's ifx accepts it, and
I think we should consider this as legal. Or what do you think?
Besides the above issues, and several issues with whitespace in
your patch (tabs/blanks), and extending the testcase so that
it covers the optional dummy for 'asis', I a fine with it.
Thanks for the work!
Harald