From 6ef1366a5516de64a6fcf35014359aba9d631c9a Mon Sep 17 00:00:00 2001 From: Thomas Koenig Date: Sun, 25 Feb 2018 09:02:32 +0000 Subject: [PATCH] re PR fortran/78238 ([OOP] ICE: verify_gimple failed, with -fdefault-integer-8) 2018-02-25 Thomas Koenig PR fortran/78238 * gfortran.h (gfc_integer_4_kind): Define. * resolve.c (resolve_select_type): Make sure that the kind of c->high is gfc_integer_4_kind. 2018-02-25 Thomas Koenig PR fortran/78238 * gfortran.dg/select_type_40.f90: New test. From-SVN: r257968 --- gcc/fortran/ChangeLog | 7 +++++++ gcc/fortran/gfortran.h | 1 + gcc/fortran/resolve.c | 9 ++++++++- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gfortran.dg/select_type_40.f90 | 9 +++++++++ 5 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gfortran.dg/select_type_40.f90 diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 6e69042c896..78e3c2e164d 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,10 @@ +2018-02-25 Thomas Koenig + + PR fortran/78238 + * gfortran.h (gfc_integer_4_kind): Define. + * resolve.c (resolve_select_type): Make sure that the + kind of c->high is gfc_integer_4_kind. + 2018-02-24 Steven G. Kargl PR fortran/30792 diff --git a/gcc/fortran/gfortran.h b/gcc/fortran/gfortran.h index f35430dcd20..94f7399885a 100644 --- a/gcc/fortran/gfortran.h +++ b/gcc/fortran/gfortran.h @@ -2921,6 +2921,7 @@ extern int gfc_numeric_storage_size; extern int gfc_character_storage_size; #define gfc_logical_4_kind 4 +#define gfc_integer_4_kind 4 /* symbol.c */ void gfc_clear_new_implicit (void); diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c index fee5b1becf5..6869bce2edb 100644 --- a/gcc/fortran/resolve.c +++ b/gcc/fortran/resolve.c @@ -8961,7 +8961,7 @@ resolve_select_type (gfc_code *code, gfc_namespace *old_ns) { vtab = gfc_find_derived_vtab (c->ts.u.derived); gcc_assert (vtab); - c->high = gfc_get_int_expr (gfc_default_integer_kind, NULL, + c->high = gfc_get_int_expr (gfc_integer_4_kind, NULL, c->ts.u.derived->hash_value); } else @@ -8970,6 +8970,13 @@ resolve_select_type (gfc_code *code, gfc_namespace *old_ns) gcc_assert (vtab && CLASS_DATA (vtab)->initializer); e = CLASS_DATA (vtab)->initializer; c->high = gfc_copy_expr (e); + if (c->high->ts.kind != gfc_integer_4_kind) + { + gfc_typespec ts; + ts.kind = gfc_integer_4_kind; + ts.type = BT_INTEGER; + gfc_convert_type_warn (c->high, &ts, 2, 0); + } } e = gfc_lval_expr_from_sym (vtab); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 60d8a9e0843..0f8219d0717 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-02-25 Thomas Koenig + + PR fortran/78238 + * gfortran.dg/select_type_40.f90: New test. + 2018-02-24 Steven G. Kargl PR fortran/30792 diff --git a/gcc/testsuite/gfortran.dg/select_type_40.f90 b/gcc/testsuite/gfortran.dg/select_type_40.f90 new file mode 100644 index 00000000000..4bfa1c7e848 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/select_type_40.f90 @@ -0,0 +1,9 @@ +! { dg-do compile } +! { dg-additional-options "-fdefault-integer-8" } +! PR 78238 - this used to cause an ICE. +! Original test cae by Gerhard Steinmetz +class(*), allocatable :: q +select type (x => q) +type is (real) +end select +end -- 2.30.2