From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2071) id CC227396DC3D; Wed, 16 Nov 2022 21:51:44 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CC227396DC3D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1668635504; bh=ooJH2vwK3XTZlkWzXZUcYEvJntxEUu/9Qzey8bG7FTU=; h=From:To:Subject:Date:From; b=hmXj+6a7ik2IYAMJKj8QSHyf1s4HiGvVUGtiG7vqGyaDAUSH1gyNbDfHNsTCs0E/J kcsgd9sOJYzvfZx+Fhg+VCinXfLTRYNUsM4lYXLDjSdf8YNrCl7GUsul/AJjfL7TvL EBfOUGdfQ749gXWh86XTZQoUBO44q8pB+MNag0S4= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Harald Anlauf To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-4113] Fortran: ICE on procedure arguments with non-integer length [PR107707] X-Act-Checkin: gcc X-Git-Author: Steve Kargl X-Git-Refname: refs/heads/master X-Git-Oldrev: c85f8dbb173f45053f6d8849d27adc98d9668769 X-Git-Newrev: bdd784fc48a283d54f5f1e3cc2a0668c14dd3bee Message-Id: <20221116215144.CC227396DC3D@sourceware.org> Date: Wed, 16 Nov 2022 21:51:44 +0000 (GMT) List-Id: https://gcc.gnu.org/g:bdd784fc48a283d54f5f1e3cc2a0668c14dd3bee commit r13-4113-gbdd784fc48a283d54f5f1e3cc2a0668c14dd3bee Author: Steve Kargl Date: Wed Nov 16 22:46:55 2022 +0100 Fortran: ICE on procedure arguments with non-integer length [PR107707] gcc/fortran/ChangeLog: PR fortran/107707 * interface.cc (gfc_compare_actual_formal): Check that we actually have integer values before asking gmp_* to use them. gcc/testsuite/ChangeLog: PR fortran/107707 * gfortran.dg/pr107707.f90: New test. Diff: --- gcc/fortran/interface.cc | 2 ++ gcc/testsuite/gfortran.dg/pr107707.f90 | 13 +++++++++++++ 2 files changed, 15 insertions(+) diff --git a/gcc/fortran/interface.cc b/gcc/fortran/interface.cc index 49dbd1d886c..616ae2b1197 100644 --- a/gcc/fortran/interface.cc +++ b/gcc/fortran/interface.cc @@ -3273,9 +3273,11 @@ gfc_compare_actual_formal (gfc_actual_arglist **ap, gfc_formal_arglist *formal, if (a->expr->ts.type == BT_CHARACTER && a->expr->ts.u.cl && a->expr->ts.u.cl->length && a->expr->ts.u.cl->length->expr_type == EXPR_CONSTANT + && a->expr->ts.u.cl->length->ts.type == BT_INTEGER && f->sym->ts.type == BT_CHARACTER && f->sym->ts.u.cl && f->sym->ts.u.cl->length && f->sym->ts.u.cl->length->expr_type == EXPR_CONSTANT + && f->sym->ts.u.cl->length->ts.type == BT_INTEGER && (f->sym->attr.pointer || f->sym->attr.allocatable || (f->sym->as && f->sym->as->type == AS_ASSUMED_SHAPE)) && (mpz_cmp (a->expr->ts.u.cl->length->value.integer, diff --git a/gcc/testsuite/gfortran.dg/pr107707.f90 b/gcc/testsuite/gfortran.dg/pr107707.f90 new file mode 100644 index 00000000000..a8be2b5b299 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr107707.f90 @@ -0,0 +1,13 @@ +! { dg-do compile } +! PR fortran/107707 - ICE in gfc_compare_actual_formal +! Contributed by G.Steinmetz + +program p + character(3), allocatable :: c + c = 'abc' + call s(c) +contains + subroutine s(x) + character(real(3)), allocatable :: x ! { dg-error "must be of INTEGER type" } + end +end