Hi Steve,
I think it’d be simpler not to create a front-end expression for the
c_null_char. Unless I’m mistaken, you only need it as an argument to pass to
build_call_expr_loc (input_location, gfor_fndecl_concat_string, …). You can
pass a pointer to the constant character, and the length is one. The variable
for length would be build_int_cst (gfc_charlen_type_node, 1). For the pointer
to the constant character, you would do:
tree nulchar = gfc_character1_type_node(gfc_character1_type_node, “nulchar”);
gfc_add_modify (&block, nulchar, build_zero_cst (gfc_character1_type_node));
tree pnulchar = gfc_build_addr_expr (NULL_TREE, nulchar);
Since the variable in this case is a known constant, there’s probably even a
better way. I just don’t remember enough, but others may help?
---
Regarding your question, you are right: you want to build the two code blocks
(you already have the content), then use: fold_build3_loc (input_location,
COND_EXPR, return_type, boolexpression, iftrue, iffalse)
You will find some logic like that in gfc_conv_intrinsic_minmaxloc() near the
comment "We switch to > or >= depending on the value of the BACK argument”. You
create ifblock and elseblock, once you have the code inside them, you make them
into trees with gfc_finish_block (becoming ifbody2 and elsebody2). Then:
tmp = fold_build3_loc (input_location, COND_EXPR, logical_type_node,
back, ifbody2, elsebody2);
Hope this helps?
Best,
FX