On Mon, Dec 09, 2024 at 06:39:19PM -0800, Steve Kargl wrote: > > I've an almost complete implementation of F_C_STRING, > but need a bit of insight on the inlining that I'm > trying to implement. In pseudo-code, F_C_STRING is > > case 1. f_c_string(string) = trim(string) // c_null_char > case 2. f_c_string(string, asis=.false.) = trim(string) // c_null_char > case 3. f_c_string(string, asis=.true.) = string // c_null_char >
Here's where I'm stuck. if (asis) { /* f_c_string(string, .true.) = string // c_null_char */ len = fold_build2_loc (input_location, PLUS_EXPR, cnode, fold_convert (cnode, lse.string_length), fold_convert (cnode, rse.string_length)); var = gfc_conv_string_tmp (se, pchar_type_node, len); tmp = build_call_expr_loc (input_location, gfor_fndecl_concat_string, 6, len, var, lse.string_length, lse.expr, rse.string_length, rse.expr); // // /* f_c_string(string, .false.) = trim(string) // c_null_char */ // // gfc_init_se (&tse, se); // conv_trim (&tse, &lse); // gfc_add_block_to_block (&se->pre, &tse.pre); // // len = fold_build2_loc (input_location, PLUS_EXPR, cnode, // fold_convert (cnode, tse.string_length), // fold_convert (cnode, rse.string_length)); // var = gfc_conv_string_tmp (se, pchar_type_node, len); // tmp = build_call_expr_loc (input_location, gfor_fndecl_concat_string, // 6, len, var, // tse.string_length, tse.expr, // rse.string_length, rse.expr); gfc_add_expr_to_block (&se->pre, tmp); se->expr = var; se->string_length = len; } else gfortran needs to select either uncommented code or the code, based on the whether 'asis' is .true. or .false. I've been unable to suss out how to set up the conditional. (It's been too long since I hacked in the trans-* files.) Any suggestions? -- Steve