From 271dd55c784a8bae4edae33f9fd79f046be7cd6c Mon Sep 17 00:00:00 2001 From: Janus Weil Date: Wed, 9 Nov 2016 21:33:24 +0100 Subject: [PATCH] [multiple changes] 2016-11-09 Mikael Morin Janus Weil PR fortran/46459 * interface.c (compare_actual_formal): Add safety checks to avoid ICE. 2016-11-09 Janus Weil PR fortran/46459 * gfortran.dg/volatile14.f90: New test. From-SVN: r242020 --- gcc/fortran/ChangeLog | 8 ++++++- gcc/fortran/interface.c | 2 ++ gcc/testsuite/ChangeLog | 5 ++++ gcc/testsuite/gfortran.dg/volatile14.f90 | 29 ++++++++++++++++++++++++ 4 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gfortran.dg/volatile14.f90 diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index ab59584852c..9c0db269f1d 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,10 +1,16 @@ +2016-11-09 Mikael Morin + Janus Weil + + PR fortran/46459 + * interface.c (compare_actual_formal): Add safety checks to avoid ICE. + 2016-11-09 Fritz O. Reese PR fortran/78259 * trans-expr.c (gfc_trans_subcomponent_assign): Guard against NULL values. -2016-11-09 Steve Kargl +2016-11-09 Steven G. Kargl Janus Weil PR fortran/60777 diff --git a/gcc/fortran/interface.c b/gcc/fortran/interface.c index 4dd432ef23d..98a61dfe3bc 100644 --- a/gcc/fortran/interface.c +++ b/gcc/fortran/interface.c @@ -3190,6 +3190,7 @@ compare_actual_formal (gfc_actual_arglist **ap, gfc_formal_arglist *formal, shape array, if the dummy argument has the VOLATILE attribute. */ if (f->sym->attr.volatile_ + && a->expr->expr_type == EXPR_VARIABLE && a->expr->symtree->n.sym->as && a->expr->symtree->n.sym->as->type == AS_ASSUMED_SHAPE && !(f->sym->as && f->sym->as->type == AS_ASSUMED_SHAPE)) @@ -3219,6 +3220,7 @@ compare_actual_formal (gfc_actual_arglist **ap, gfc_formal_arglist *formal, dummy argument has the VOLATILE attribute. */ if (f->sym->attr.volatile_ + && a->expr->expr_type == EXPR_VARIABLE && a->expr->symtree->n.sym->attr.pointer && a->expr->symtree->n.sym->as && !(f->sym->as diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index bc80499f3d0..f295754706f 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2016-11-09 Janus Weil + + PR fortran/46459 + * gfortran.dg/volatile14.f90: New test. + 2016-11-09 Uros Bizjak PR target/78262 diff --git a/gcc/testsuite/gfortran.dg/volatile14.f90 b/gcc/testsuite/gfortran.dg/volatile14.f90 new file mode 100644 index 00000000000..15730c83f9b --- /dev/null +++ b/gcc/testsuite/gfortran.dg/volatile14.f90 @@ -0,0 +1,29 @@ +! { dg-do compile } +! +! PR 46459: ICE (segfault): Invalid read in compare_actual_formal [error recovery] +! +! Contributed by Harald Anlauf + + call sub (1) +contains + subroutine sub (j) + integer, volatile :: j + end subroutine +end + +subroutine sub1 () + call sub2 (1) ! { dg-error "Explicit interface required" } +end subroutine + +subroutine sub2 (j) + integer, volatile :: j +end subroutine + +subroutine sub3 () + interface + subroutine sub2 (j) + integer, volatile :: j + end subroutine + end interface + call sub2 (1) +end subroutine -- 2.30.2