[patch, fortran] Implement constant-folding for TRANSFER intrinsic.

Brooks Moses brooks.moses@codesourcery.com
Sat May 12 17:44:00 GMT 2007


At 10:28 AM 5/12/2007, Tobias Schlüter wrote:
>>My inclination would be to do the cosmetic and small fixes to this and go 
>>ahead and commit it and then work on the alternate-character-set 
>>hypotheticality and the derived-type spacing stuff in follow-up patches, 
>>since AFAIK this doesn't cause anything to break that worked 
>>previously.  But that's not a strong inclination, and I'll let Paul and 
>>FX make the call on that.  :)
>
>I think we should assert that we're not dealing with derived types, since 
>otherwise we would leave the user with a potentially hard-to-find 
>error.  Apart from that, I agree with this course of action.

That sounds like it might be a good idea.

If we do that, my suggestion would be to take the old code at the head of 
gfc_simplify_transfer that returns NULL unless gfc_init_expr, and make that 
conditional on SOURCE or MOLD being a derived type.  That way, instead of 
ICEing on a derived type argument that could be handled at runtime, we'll 
leave it unsimplified and let the runtime handle it.  Something like (in 
semi-pseudocode):

   /* Derived types are not known to be handled correctly yet.  */
   if (type(source) is BT_DERIVED || type(mold) is BT_DERIVED)
     {
        if (gfc_init_expr)
          gfc_error ("TRANSFER intrinsic not implemented for initialization"
                     " at %L", &source->where);
        return NULL;
     }

- Brooks



More information about the Fortran mailing list