diff options
author | Tobias Burnus <burnus@net-b.de> | 2012-08-20 21:49:46 +0200 |
---|---|---|
committer | Tobias Burnus <burnus@gcc.gnu.org> | 2012-08-20 21:49:46 +0200 |
commit | ed0ba472c654095656fe1da371ee1a710fce2cf0 (patch) | |
tree | 4f00eaee89fd24bfe17ce28b877ab8f4b661dab7 | |
parent | 07bc8ae8abd68eaf968f77f453e33ec60c371bb3 (diff) | |
download | gcc-ed0ba472c654095656fe1da371ee1a710fce2cf0.zip gcc-ed0ba472c654095656fe1da371ee1a710fce2cf0.tar.gz gcc-ed0ba472c654095656fe1da371ee1a710fce2cf0.tar.bz2 |
re PR fortran/54301 (Add optional warning if pointer assigning a local variable to a nonlocal pointer)
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
* gfortran.dg/warn_target_lifetime_2.f90: New.
From-SVN: r190542
-rw-r--r-- | gcc/fortran/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/fortran/expr.c | 1 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/gfortran.dg/warn_target_lifetime_2.f90 | 10 |
4 files changed, 22 insertions, 0 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index de255ea..4992ecf 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -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. diff --git a/gcc/fortran/expr.c b/gcc/fortran/expr.c index 6f1283d..bc1f5e3 100644 --- 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; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 686e041..0b1bf5a 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -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 diff --git a/gcc/testsuite/gfortran.dg/warn_target_lifetime_2.f90 b/gcc/testsuite/gfortran.dg/warn_target_lifetime_2.f90 new file mode 100644 index 0000000..bfcb7ac --- /dev/null +++ b/gcc/testsuite/gfortran.dg/warn_target_lifetime_2.f90 @@ -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 |