This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [Patch, Fortran] PR54301 - add warning for pointer might outlive its target


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;


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]