------- Comment #11 from burnus at gcc dot gnu dot org 2010-06-20 18:31 ------- + /* A temporary is not needed if the function is not contained and the + variable local. */ + if (!sym->attr.use_assoc + && !sym->attr.in_common + && !sym->attr.pointer + && !sym->attr.target + && expr2->value.function.esym + && !expr2->value.function.esym->attr.contained) + return false;
Does use_assoc also include host-associated variables - it should for this check. (I have not checked.) Additionally allowed without temporary: sym->attr.dummy && sym->attr.intent == INTENT_OUT as "If a dummy argument has INTENT (OUT), the actual argument becomes undefined at the time the association is established" thus also any access via any method to that variable is undefined - and thus invalid. I think that the LHS is a dummy argument is a very common case and thus it makes sense to optimize for INTENT(OUT). + && expr2->value.function.esym + && !expr2->value.function.esym->attr.contained) Doesn't this not also unnecessarily prohibit contains subroutine a() dimension :: x(4) x = f() end subroutine function f() as "f" is contained (in the same namespace as "a"? Or is this not set for the "sym" as available in the namespace of "a"? Otherwise, the patch looks OK. > + /* TODO a function that could correctly be declared PURE but is not > + could do with returning false as well. */ (Well said, but not easily to be implemented. Actually, that could be a weaker check as pure routines may not do I/O (on file units) or use (ERROR) STOP and the argument INTENT(IN)/VALUE constraints do not matter either.) -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44582