diff options
author | Tobias Burnus <burnus@net-b.de> | 2011-10-14 17:09:21 +0200 |
---|---|---|
committer | Tobias Burnus <burnus@gcc.gnu.org> | 2011-10-14 17:09:21 +0200 |
commit | 85ff29389d2a4e9cae1efabb1acfb8c8927d7e11 (patch) | |
tree | f0572893ffbfdaa5ae96d940b4c171a86826ca21 | |
parent | 8c3532055ae44c448bd0bff8952f60ce68e2f178 (diff) | |
download | gcc-85ff29389d2a4e9cae1efabb1acfb8c8927d7e11.zip gcc-85ff29389d2a4e9cae1efabb1acfb8c8927d7e11.tar.gz gcc-85ff29389d2a4e9cae1efabb1acfb8c8927d7e11.tar.bz2 |
re PR fortran/50718 (ICE (fold_convert) with -fcheck=pointer)
2011-10-14 Tobias Burnus <burnus@net-b.de>
PR fortran/50718
* trans-expr.c (gfc_conv_procedure_call): Fix -fcheck=pointer
for dummy arguments with VALUE attribute.
2011-10-14 Tobias Burnus <burnus@net-b.de>
PR fortran/50718
* gfortran.dg/pointer_check_11.f90: New.
* gfortran.dg/pointer_check_12.f90: New.
From-SVN: r179988
-rw-r--r-- | gcc/fortran/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/fortran/trans-expr.c | 10 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/testsuite/gfortran.dg/pointer_check_11.f90 | 24 | ||||
-rw-r--r-- | gcc/testsuite/gfortran.dg/pointer_check_12.f90 | 22 |
5 files changed, 66 insertions, 2 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 5e3d024..3cff8d7 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2011-10-14 Tobias Burnus <burnus@net-b.de> + + PR fortran/50718 + * trans-expr.c (gfc_conv_procedure_call): Fix -fcheck=pointer + for dummy arguments with VALUE attribute. + 2011-10-11 Tobias Burnus <burnus@net-b.de> Janus Weil <janus@gcc.gnu.org> diff --git a/gcc/fortran/trans-expr.c b/gcc/fortran/trans-expr.c index ca0523f..09b98d0 100644 --- a/gcc/fortran/trans-expr.c +++ b/gcc/fortran/trans-expr.c @@ -3357,10 +3357,16 @@ gfc_conv_procedure_call (gfc_se * se, gfc_symbol * sym, else goto end_pointer_check; + tmp = parmse.expr; + + /* If the argument is passed by value, we need to strip the + INDIRECT_REF. */ + if (!POINTER_TYPE_P (TREE_TYPE (parmse.expr))) + tmp = gfc_build_addr_expr (NULL_TREE, tmp); cond = fold_build2_loc (input_location, EQ_EXPR, - boolean_type_node, parmse.expr, - fold_convert (TREE_TYPE (parmse.expr), + boolean_type_node, tmp, + fold_convert (TREE_TYPE (tmp), null_pointer_node)); } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index e04f527..83d14d0 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2011-10-14 Tobias Burnus <burnus@net-b.de> + + PR fortran/50718 + * gfortran.dg/pointer_check_11.f90: New. + * gfortran.dg/pointer_check_12.f90: New. + 2011-10-14 Paolo Carlini <paolo.carlini@oracle.com> PR c++/38174 diff --git a/gcc/testsuite/gfortran.dg/pointer_check_11.f90 b/gcc/testsuite/gfortran.dg/pointer_check_11.f90 new file mode 100644 index 0000000..b6aa79a --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pointer_check_11.f90 @@ -0,0 +1,24 @@ +! { dg-do run } +! { dg-options "-fcheck=all" } +! +! { dg-shouldfail "Pointer check" } +! { dg-output "Fortran runtime error: Pointer actual argument 'y' is not associated" } +! +! +! PR fortran/50718 +! +! Was failing (ICE) with -fcheck=pointer if the dummy had the value attribute. + +type t + integer :: p +end type t + +type(t), pointer :: y => null() + +call sub(y) ! Invalid: Nonassociated pointer + +contains + subroutine sub (x) + type(t), value :: x + end subroutine +end diff --git a/gcc/testsuite/gfortran.dg/pointer_check_12.f90 b/gcc/testsuite/gfortran.dg/pointer_check_12.f90 new file mode 100644 index 0000000..cfef70e --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pointer_check_12.f90 @@ -0,0 +1,22 @@ +! { dg-do run } +! { dg-options "-fcheck=all" } +! +! { dg-shouldfail "Pointer check" } +! { dg-output "Fortran runtime error: Pointer actual argument 'p' is not associated" } +! +! PR fortran/50718 +! +! Was failing with -fcheck=pointer: Segfault at run time + +integer, pointer :: p => null() + +call sub2(%val(p)) ! Invalid: Nonassociated pointer +end + +! Not quite correct dummy, but if one uses VALUE, gfortran +! complains about a missing interface - which we cannot use +! if we want to use %VAL(). + +subroutine sub2(p) + integer :: p +end subroutine sub2 |