diff options
author | Janus Weil <janus@gcc.gnu.org> | 2010-09-20 23:42:54 +0200 |
---|---|---|
committer | Janus Weil <janus@gcc.gnu.org> | 2010-09-20 23:42:54 +0200 |
commit | 48dbbcd6e29e7520b91dce52f492fa07fb6e4aad (patch) | |
tree | e6777450f7b259237fcf188c6329216d441178a5 /gcc | |
parent | ad78b8a6887aef944aae522884f8c9e7b91fb860 (diff) | |
download | gcc-48dbbcd6e29e7520b91dce52f492fa07fb6e4aad.zip gcc-48dbbcd6e29e7520b91dce52f492fa07fb6e4aad.tar.gz gcc-48dbbcd6e29e7520b91dce52f492fa07fb6e4aad.tar.bz2 |
re PR fortran/45438 ([OOP] ICE with -fcheck=pointer)
2010-09-20 Janus Weil <janus@gcc.gnu.org>
PR fortran/45438
* trans-expr.c (gfc_conv_procedure_call): Fix pointer checking for
TBPs, PPCs and pointer/allocatable components.
2010-09-20 Janus Weil <janus@gcc.gnu.org>
PR fortran/45438
* gfortran.dg/pointer_check_7.f90: New.
From-SVN: r164462
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/fortran/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/fortran/trans-expr.c | 31 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/gfortran.dg/pointer_check_7.f90 | 36 |
4 files changed, 57 insertions, 21 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index d80a522..d9777bf 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2010-09-20 Janus Weil <janus@gcc.gnu.org> + + PR fortran/45438 + * trans-expr.c (gfc_conv_procedure_call): Fix pointer checking for + TBPs, PPCs and pointer/allocatable components. + 2010-09-20 Paul Thomas <pault@gcc.gnu.org> PR fortran/45081 diff --git a/gcc/fortran/trans-expr.c b/gcc/fortran/trans-expr.c index 8d4295f..9b24cad 100644 --- a/gcc/fortran/trans-expr.c +++ b/gcc/fortran/trans-expr.c @@ -3169,27 +3169,16 @@ gfc_conv_procedure_call (gfc_se * se, gfc_symbol * sym, if (gfc_option.rtcheck & GFC_RTCHECK_POINTER && e != NULL) { - symbol_attribute *attr; + symbol_attribute attr; char *msg; tree cond; - if (e->expr_type == EXPR_VARIABLE) - attr = &e->symtree->n.sym->attr; - else if (e->expr_type == EXPR_FUNCTION) - { - /* For intrinsic functions, the gfc_attr are not available. */ - if (e->symtree->n.sym->attr.generic && e->value.function.isym) - goto end_pointer_check; - - if (e->symtree->n.sym->attr.generic) - attr = &e->value.function.esym->attr; - else - attr = &e->symtree->n.sym->result->attr; - } + if (e->expr_type == EXPR_VARIABLE || e->expr_type == EXPR_FUNCTION) + attr = gfc_expr_attr (e); else goto end_pointer_check; - if (attr->optional) + if (attr.optional) { /* If the actual argument is an optional pointer/allocatable and the formal argument takes an nonpointer optional value, @@ -3198,16 +3187,16 @@ gfc_conv_procedure_call (gfc_se * se, gfc_symbol * sym, See Fortran 2003, Section 12.4.1.6 item (7)+(8). */ tree present, null_ptr, type; - if (attr->allocatable + if (attr.allocatable && (fsym == NULL || !fsym->attr.allocatable)) asprintf (&msg, "Allocatable actual argument '%s' is not " "allocated or not present", e->symtree->n.sym->name); - else if (attr->pointer + else if (attr.pointer && (fsym == NULL || !fsym->attr.pointer)) asprintf (&msg, "Pointer actual argument '%s' is not " "associated or not present", e->symtree->n.sym->name); - else if (attr->proc_pointer + else if (attr.proc_pointer && (fsym == NULL || !fsym->attr.proc_pointer)) asprintf (&msg, "Proc-pointer actual argument '%s' is not " "associated or not present", @@ -3231,15 +3220,15 @@ gfc_conv_procedure_call (gfc_se * se, gfc_symbol * sym, } else { - if (attr->allocatable + if (attr.allocatable && (fsym == NULL || !fsym->attr.allocatable)) asprintf (&msg, "Allocatable actual argument '%s' is not " "allocated", e->symtree->n.sym->name); - else if (attr->pointer + else if (attr.pointer && (fsym == NULL || !fsym->attr.pointer)) asprintf (&msg, "Pointer actual argument '%s' is not " "associated", e->symtree->n.sym->name); - else if (attr->proc_pointer + else if (attr.proc_pointer && (fsym == NULL || !fsym->attr.proc_pointer)) asprintf (&msg, "Proc-pointer actual argument '%s' is not " "associated", e->symtree->n.sym->name); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 13d783d..d1bf076 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2010-09-20 Janus Weil <janus@gcc.gnu.org> + + PR fortran/45438 + * gfortran.dg/pointer_check_7.f90: New. + 2010-09-20 Jakub Jelinek <jakub@redhat.com> PR rtl-optimization/45728 diff --git a/gcc/testsuite/gfortran.dg/pointer_check_7.f90 b/gcc/testsuite/gfortran.dg/pointer_check_7.f90 new file mode 100644 index 0000000..0f6dcdc --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pointer_check_7.f90 @@ -0,0 +1,36 @@ +! { dg-do compile } +! { dg-options "-fcheck=pointer" } +! +! PR 45438: [4.6 Regression] [OOP] ICE with -fcheck=pointer +! +! Contributed by Salvatore Filippone <sfilippone@uniroma2.it> + +module base_mat_mod + + implicit none + + type :: base_sparse_mat + contains + procedure :: get_fmt + end type + +contains + + function get_fmt(a) result(res) + class(base_sparse_mat), intent(in) :: a + character(len=5) :: res + res = 'NULL' + end function + + subroutine errlog(name) + character(len=*) :: name + end subroutine + + subroutine test (a) + class(base_sparse_mat), intent(in) :: a + call errlog(a%get_fmt()) + end subroutine + +end module + +! { dg-final { cleanup-modules "base_mat_mod" } } |