diff options
author | Harald Anlauf <anlauf@gmx.de> | 2021-05-27 13:55:11 +0200 |
---|---|---|
committer | Harald Anlauf <anlauf@gmx.de> | 2021-05-27 13:55:11 +0200 |
commit | 9d3a953ec4d2695e9a6bfa5f22655e2aea47a973 (patch) | |
tree | 7bb6b9b2f47e702c2f21e42f3e615015eaf7fde3 /gcc | |
parent | 262e75d22c350acbdf4c1fb4f224cc5d3d711eff (diff) | |
download | gcc-9d3a953ec4d2695e9a6bfa5f22655e2aea47a973.zip gcc-9d3a953ec4d2695e9a6bfa5f22655e2aea47a973.tar.gz gcc-9d3a953ec4d2695e9a6bfa5f22655e2aea47a973.tar.bz2 |
PR fortran/100656 - prevent ICE in gfc_conv_expr_present
gcc/fortran/ChangeLog:
PR fortran/100656
* trans-array.c (gfc_conv_ss_startstride): Do not call check for
presence of a dummy argument when a symbol actually refers to a
non-dummy.
gcc/testsuite/ChangeLog:
PR fortran/100656
* gfortran.dg/bounds_check_22.f90: New test.
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/fortran/trans-array.c | 5 | ||||
-rw-r--r-- | gcc/testsuite/gfortran.dg/bounds_check_22.f90 | 12 |
2 files changed, 15 insertions, 2 deletions
diff --git a/gcc/fortran/trans-array.c b/gcc/fortran/trans-array.c index 6d38ea7..7eeef55 100644 --- a/gcc/fortran/trans-array.c +++ b/gcc/fortran/trans-array.c @@ -4718,8 +4718,9 @@ done: /* For optional arguments, only check bounds if the argument is present. */ - if (expr->symtree->n.sym->attr.optional - || expr->symtree->n.sym->attr.not_always_present) + if ((expr->symtree->n.sym->attr.optional + || expr->symtree->n.sym->attr.not_always_present) + && expr->symtree->n.sym->attr.dummy) tmp = build3_v (COND_EXPR, gfc_conv_expr_present (expr->symtree->n.sym), tmp, build_empty_stmt (input_location)); diff --git a/gcc/testsuite/gfortran.dg/bounds_check_22.f90 b/gcc/testsuite/gfortran.dg/bounds_check_22.f90 new file mode 100644 index 0000000..a84e3dd --- /dev/null +++ b/gcc/testsuite/gfortran.dg/bounds_check_22.f90 @@ -0,0 +1,12 @@ +! { dg-do compile } +! { dg-options "-fcheck=bounds" } +! PR fortran/100656 - ICE in gfc_conv_expr_present + +subroutine s(x) + character(:), allocatable, optional :: x(:) + if ( present(x) ) then + if ( allocated(x) ) then + x = 'a' // x // 'e' + end if + end if +end |