Hi Thomas,

Thomas Koenig wrote:
do you think that -Wtarget-lifetime should be included with -Wall?
I think so, because the code flagged is certainly invalid, and likely
to cause random errors.

I concur. However, that's what the current version in the trunk does: -Wall implies -Wtarget-lifetime.

On the other hand, I just realized that "attr.result" is not set if the function symbols is also its result symbol – hence, there is no warning for:

function f()
  integer, pointer :: f
  integer, target :: t
  f => t
end

I think the following patch will fix that. I will package, regtest and commit it later.

Tobias

--- a/gcc/fortran/expr.c
+++ b/gcc/fortran/expr.c
@@ -3673,6 +3673,7 @@ gfc_check_pointer_assign (gfc_expr *lvalue, gfc_expr *rvalue)

       warn = lvalue->symtree->n.sym->attr.dummy
             || lvalue->symtree->n.sym->attr.result
+            || lvalue->symtree->n.sym->attr.function
             || lvalue->symtree->n.sym->attr.host_assoc
             || lvalue->symtree->n.sym->attr.use_assoc
             || lvalue->symtree->n.sym->attr.in_common;

Reply via email to