------- Comment #6 from sgk at troutmask dot apl dot washington dot edu 2006-08-03 05:09 ------- Subject: Re: [4.2 Regression]: Optional argument failed
On Thu, Aug 03, 2006 at 04:49:33AM -0000, kargl at gcc dot gnu dot org wrote: > > (gdb) print *isym > $28 = {name = 0x8869b61 "__convert_i4_r4", > lib_name = 0x8869b61 "__convert_i4_r4", formal = 0x0, ts = {type = BT_REAL, > kind = 4, derived = 0x0, cl = 0x0}, elemental = 1, pure = 0, generic = 0, > specific = 0, actual_ok = 0, standard = 1, noreturn = 0, simplify = { > > Note, the __convert function is marked as elemental. I don't know why > this is so. > OK, I understand the problem. Even though the __convert functions are not elemental fortran procedures, gfortran marks these as elemental to use the machinary to deal with both scalar and array arguments. The upshot, AFAICT, is that we need to special case the __convert functions in resolve.c. The following patch allows a mangled version of HJ's testcase to compile. Index: resolve.c =================================================================== --- resolve.c (revision 115827) +++ resolve.c (working copy) @@ -1012,7 +1012,8 @@ && arg->expr->symtree->n.sym->attr.optional && formal_optional && arg->expr->rank - && (set_by_optional || arg->expr->rank != rank)) + && (set_by_optional || arg->expr->rank != rank) + && !(isym && isym->generic_id == GFC_ISYM_CONVERSION)) { gfc_error ("'%s' at %L is an array and OPTIONAL; it cannot " "therefore be an actual argument of an ELEMENTAL " -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28548