Message ID | trinity-673a14f6-969b-4250-9da8-faa12ce14bf9-1635454985371@3c-app-gmx-bap70 |
---|---|
State | New |
Headers | show |
Series | PR fortran/99853 - ICE: Cannot convert 'LOGICAL(4)' to 'INTEGER(8)' (etc.) | expand |
On Thu, 28 Oct 2021 23:03:05 +0200 Harald Anlauf via Fortran <fortran@gcc.gnu.org> wrote: > Dear Fortranners, > > the original fix by Steve was lingering in the PR. > > We did ICE in situations where in a SELECT CASE a kind conversion > was deemed necessary, but it did involve different types. > The check gfc_convert_type_warn () was invoked with arguments > requesting to generate an internal error. A regular gfc_error > is good enough here. > > Regtested on x86_64-pc-linux-gnu. OK? Sounds plausible but i cannot approve it. PS: git commit --author 'Steve Kargl <sgk@troutmask.apl.washington.edu>' would give Steve due credit i suppose. Or throw in --amend if you applied it already to your local tree (e.g rebase -i and reword the message, then git commit --amend --author ...). HTH. > > Thanks, also to Steve, thanks, > > Harald > > > Fortran: generate regular error on invalid conversions of CASE expressions > > gcc/fortran/ChangeLog: > > PR fortran/99853 > * resolve.c (resolve_select): Generate regular gfc_error on > invalid conversions instead of an gfc_internal_error. > > gcc/testsuite/ChangeLog: > > PR fortran/99853 > * gfortran.dg/pr99853.f90: New test. >
Committed as simple and obvious after discussion in PR. Harald Am 28.10.21 um 23:03 schrieb Harald Anlauf via Fortran: > Dear Fortranners, > > the original fix by Steve was lingering in the PR. > > We did ICE in situations where in a SELECT CASE a kind conversion > was deemed necessary, but it did involve different types. > The check gfc_convert_type_warn () was invoked with arguments > requesting to generate an internal error. A regular gfc_error > is good enough here. > > Regtested on x86_64-pc-linux-gnu. OK? > > Thanks, also to Steve, > > Harald > > > Fortran: generate regular error on invalid conversions of CASE expressions > > gcc/fortran/ChangeLog: > > PR fortran/99853 > * resolve.c (resolve_select): Generate regular gfc_error on > invalid conversions instead of an gfc_internal_error. > > gcc/testsuite/ChangeLog: > > PR fortran/99853 > * gfortran.dg/pr99853.f90: New test. >
diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c index af71b132dec..8da396b32ec 100644 --- a/gcc/fortran/resolve.c +++ b/gcc/fortran/resolve.c @@ -8770,11 +8770,11 @@ resolve_select (gfc_code *code, bool select_type) if (cp->low != NULL && case_expr->ts.kind != gfc_kind_max(case_expr, cp->low)) - gfc_convert_type_warn (case_expr, &cp->low->ts, 2, 0); + gfc_convert_type_warn (case_expr, &cp->low->ts, 1, 0); if (cp->high != NULL && case_expr->ts.kind != gfc_kind_max(case_expr, cp->high)) - gfc_convert_type_warn (case_expr, &cp->high->ts, 2, 0); + gfc_convert_type_warn (case_expr, &cp->high->ts, 1, 0); } } } diff --git a/gcc/testsuite/gfortran.dg/pr99853.f90 b/gcc/testsuite/gfortran.dg/pr99853.f90 new file mode 100644 index 00000000000..421a656bec2 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr99853.f90 @@ -0,0 +1,29 @@ +! { dg-do compile } +! { dg-options "-std=f2018" } +! PR fortran/99853 + +subroutine s1 () + select case (.true.) ! { dg-error "Cannot convert" } + case (1_8) ! { dg-error "must be of type LOGICAL" } + end select +end + +subroutine s2 () + select case (.false._1) ! { dg-error "Cannot convert" } + case (2:3) ! { dg-error "must be of type LOGICAL" } + end select +end + +subroutine s3 () + select case (3_2) ! { dg-error "Cannot convert" } + case (.false.) ! { dg-error "must be of type INTEGER" } + end select +end + +subroutine s4 (i) + select case (i) ! { dg-error "Cannot convert" } + case (.true._8) ! { dg-error "must be of type INTEGER" } + end select +end + +! { dg-prune-output "Cannot convert" }