From: Tobias Burnus Date: Fri, 14 Oct 2011 15:09:21 +0000 (+0200) Subject: re PR fortran/50718 (ICE (fold_convert) with -fcheck=pointer) X-Git-Tag: releases/gcc-4.7.0~3106 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=85ff29389d2a4e9cae1efabb1acfb8c8927d7e11;p=thirdparty%2Fgcc.git re PR fortran/50718 (ICE (fold_convert) with -fcheck=pointer) 2011-10-14 Tobias Burnus PR fortran/50718 * trans-expr.c (gfc_conv_procedure_call): Fix -fcheck=pointer for dummy arguments with VALUE attribute. 2011-10-14 Tobias Burnus PR fortran/50718 * gfortran.dg/pointer_check_11.f90: New. * gfortran.dg/pointer_check_12.f90: New. From-SVN: r179988 --- diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 5e3d024b8978..3cff8d7cc546 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2011-10-14 Tobias Burnus + + PR fortran/50718 + * trans-expr.c (gfc_conv_procedure_call): Fix -fcheck=pointer + for dummy arguments with VALUE attribute. + 2011-10-11 Tobias Burnus Janus Weil diff --git a/gcc/fortran/trans-expr.c b/gcc/fortran/trans-expr.c index ca0523fedca2..09b98d03fafc 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 e04f5277d027..83d14d0656cb 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2011-10-14 Tobias Burnus + + PR fortran/50718 + * gfortran.dg/pointer_check_11.f90: New. + * gfortran.dg/pointer_check_12.f90: New. + 2011-10-14 Paolo Carlini 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 000000000000..b6aa79ae260e --- /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 000000000000..cfef70e59995 --- /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