https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82649
Bug ID: 82649 Summary: (PDT) Invalid error for assumed parameters in ALLOCATE typespec Product: gcc Version: 8.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: pault at gcc dot gnu.org Target Milestone: --- From Reinhold Bader: module matrix_mod_assumed_02 implicit none type :: matrix(rk, n, m) integer, kind :: rk integer, len :: n, m real(rk) :: entry(n, m) end type matrix integer, parameter :: rk=kind(1.d0) integer, parameter :: mm=20, nn=15 contains subroutine factory(o_matrix) type(matrix(rk, *, *)), allocatable :: o_matrix allocate(matrix(rk, *, *) :: o_matrix) end subroutine end module program test use matrix_mod_assumed_02 implicit none type(matrix(rk, nn, mm)), allocatable :: o_matrix call factory(o_matrix) if (o_matrix%n == nn .and. o_matrix%m == mm) then write(*,*) 'OK' else write(*,*) o_matrix%n, o_matrix%m write(*,*) 'FAIL' end if end program test par_assumed_02_pos.f90:16:13: allocate(matrix(rk, *, *) :: o_matrix) 1 Error: The type parameter spec list in the type-spec at (1) cannot contain ASSUMED or DEFERRED parameters This is easily fixed at match.c:4010 by eliminating the error for assumed parameters: Index: ../trunk/gcc/fortran/match.c =================================================================== *** ../trunk/gcc/fortran/match.c (revision 253969) --- ../trunk/gcc/fortran/match.c (working copy) *************** gfc_match_allocate (void) *** 4007,4016 **** /* TODO understand why this error does not appear but, instead, the derived type is caught as a variable in primary.c. */ ! if (gfc_spec_list_type (type_param_spec_list, NULL) != SPEC_EXPLICIT) { gfc_error ("The type parameter spec list in the type-spec at " ! "%L cannot contain ASSUMED or DEFERRED parameters", &old_locus); goto cleanup; } --- 4007,4016 ---- /* TODO understand why this error does not appear but, instead, the derived type is caught as a variable in primary.c. */ ! if (gfc_spec_list_type (type_param_spec_list, NULL) == SPEC_DEFERRED) { gfc_error ("The type parameter spec list in the type-spec at " ! "%L cannot contain DEFERRED parameters", &old_locus); goto cleanup; } This, however, exposes the real problem and the reason why the error was introduced in the first place. [pault@pc30 reinhold]$ ~/irun/bin/gfortran -static-libgfortran par_assumed_02_pos.f90 -fdump-tree-original par_assumed_02_pos.f90:16:0: allocate(matrix(rk, *, *) :: o_matrix) internal compiler error: Segmentation fault 0xcc160f crash_signal ../../trunk/gcc/toplev.c:326 0x70419d insert_parameter_exprs ../../trunk/gcc/fortran/decl.c:3154 0x7204ed gfc_traverse_expr(gfc_expr*, gfc_symbol*, bool (*)(gfc_expr*, gfc_symbol*, int*), int) ../../trunk/gcc/fortran/expr.c:4636 0x7cf492 structure_alloc_comps ../../trunk/gcc/fortran/trans-array.c:9041 0x7d10f0 gfc_allocate_pdt_comp(gfc_symbol*, tree_node*, int, gfc_actual_arglist*) ../../trunk/gcc/fortran/trans-array.c:9300 0x84d2ad gfc_trans_allocate(gfc_code*) ../../trunk/gcc/fortran/trans-stmt.c:6407 0x7bacf7 trans_code ../../trunk/gcc/fortran/trans.c:1976 0x7ee087 gfc_generate_function_code(gfc_namespace*) ../../trunk/gcc/fortran/trans-decl.c:6422 0x7bfc91 gfc_generate_module_code(gfc_namespace*) ../../trunk/gcc/fortran/trans.c:2202 0x7725cb translate_all_program_units ../../trunk/gcc/fortran/parse.c:6075 0x7725cb gfc_parse_file() ../../trunk/gcc/fortran/parse.c:6291 0x7b70ff gfc_be_parse_file ../../trunk/gcc/fortran/f95-lang.c:204 Please submit a full bug report, As far as I can see at the moment, this can only be fixed by the introduction of a PDT descriptor for allocatable and pointer objects. I have been walking around this problem trying to come up with an alternative but have been unable to do so. I have a week away in a cottage in Cornwall soon. If I haven't come up with anything by then, I will bite the bullet and will implement the descriptor. Cheers Paul