------- Comment #13 from pault at gcc dot gnu dot org 2007-03-26 12:43 ------- (In reply to comment #11) > (In reply to comment #10) Thomas,
It does not look too bad: Look at the tail end of array_transfer - gfc_trans_create_temp_array (&se->pre, &se->post, se->loop, info, mold_type, false, true, false); /* Cast the pointer to the result. */ tmp = gfc_conv_descriptor_data_get (info->descriptor); Will produce a temporary array of the right dimension, together with its descriptor. For minmaxloc, mold_type will have to be replaced by the TREE_TYPE of the result (gfc_array_index_type, I suppose? or else, you will have to use gfc_typenode_for_spec (&expr->ts);, I think). tmp will now be a pointer to your result array. This needs to appear fairly early on in minmaxloc, so that the array can be set to zero to initialize it and so that the location can be tranferred to it. The standard checks will have to be made that ss->loop exists etc.. - just check some of the other array valued in-line intrinsics. Having done this, you will need to replace the line (~2049), folowing "remember where we are", with a loop over the n dimensions (note, we do not have to restrict ourselves to one dimension:) ). Something like: /* Remember where we are. */ for (n = 0; n < loop.dimen; n++) { pos = build_fold_indirect_ref (gfc_conv_array_data info->descriptor)); pos = gfc_build_array_ref (pos, build_int_cst (gfc_array_index_type, n)) gfc_add_modify_expr (&ifblock, pos, loop.loopvar[n]); } should bang the position into the result array, which is transferred at the end with se->expr = info->descriptor; Good luck Cheers Paul -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31067