Patchwork [Fortran,commit] -Wtarget-lifetime: Fix omission

login
register
mail settings
Submitter Tobias Burnus
Date Aug. 20, 2012, 7:51 p.m.
Message ID <5032952B.4070704@net-b.de>
Download mbox | patch
Permalink /patch/178923/
State New
Headers show

Comments

Tobias Burnus - Aug. 20, 2012, 7:51 p.m.
Committed as Rev. 190542

Tobias

Patch

Index: gcc/testsuite/gfortran.dg/warn_target_lifetime_2.f90
===================================================================
--- gcc/testsuite/gfortran.dg/warn_target_lifetime_2.f90	(Revision 0)
+++ gcc/testsuite/gfortran.dg/warn_target_lifetime_2.f90	(Arbeitskopie)
@@ -0,0 +1,10 @@ 
+! { dg-do compile }
+! { dg-options "-Wtarget-lifetime" }
+!
+! PR fortran/54301
+!
+function f()
+  integer, pointer :: f
+  integer, target :: t
+  f => t ! { dg-warning "Pointer at .1. in pointer assignment might outlive the pointer target" }
+end
Index: gcc/testsuite/ChangeLog
===================================================================
--- gcc/testsuite/ChangeLog	(Revision 190541)
+++ gcc/testsuite/ChangeLog	(Arbeitskopie)
@@ -1,3 +1,8 @@ 
+2012-08-20  Tobias Burnus  <burnus@net-b.de>
+
+	PR fortran/54301
+	* gfortran.dg/warn_target_lifetime_2.f90: New.
+
 2012-08-20  Paolo Carlini  <paolo.carlini@oracle.com>
 
 	PR c++/10416
Index: gcc/fortran/expr.c
===================================================================
--- gcc/fortran/expr.c	(Revision 190541)
+++ gcc/fortran/expr.c	(Arbeitskopie)
@@ -3673,6 +3673,7 @@  gfc_check_pointer_assign (gfc_expr *lvalue, gfc_ex
 
       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: gcc/fortran/ChangeLog
===================================================================
--- gcc/fortran/ChangeLog	(Revision 190541)
+++ gcc/fortran/ChangeLog	(Arbeitskopie)
@@ -1,6 +1,12 @@ 
 2012-08-20  Tobias Burnus  <burnus@net-b.de>
 
 	PR fortran/54301
+	* expr.c (gfc_check_pointer_assign): Warn when a pointer,
+	which is a function result, might outlive its target.
+
+2012-08-20  Tobias Burnus  <burnus@net-b.de>
+
+	PR fortran/54301
 	* expr.c (gfc_check_pointer_assign): Warn when the pointer
 	might outlive its target.
 	* gfortran.h (struct gfc_option_t): Add warn_target_lifetime.