From 84083a711ee6b84f42a6d33c45784d660cf4f514 Mon Sep 17 00:00:00 2001 From: Janus Weil Date: Wed, 13 Mar 2019 20:52:23 +0100 Subject: [PATCH] re PR fortran/89601 ([PDT] ICE: Segmentation fault (in resolve_component)) fix PR 89601 2019-03-13 Janus Weil PR fortran/89601 * decl.c (gfc_match_formal_arglist): Reject empty type parameter lists. (gfc_match_derived_decl): Mark as PDT only if type parameter list was matched successfully. 2019-03-13 Janus Weil PR fortran/89601 * gfortran.dg/pdt_16.f03: Modified to avoid follow-up errors. * gfortran.dg/pdt_30.f90: New test case. From-SVN: r269658 --- gcc/fortran/ChangeLog | 7 +++++++ gcc/fortran/decl.c | 14 ++++++++++++-- gcc/testsuite/ChangeLog | 6 ++++++ gcc/testsuite/gfortran.dg/pdt_16.f03 | 1 - gcc/testsuite/gfortran.dg/pdt_30.f90 | 17 +++++++++++++++++ 5 files changed, 42 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/gfortran.dg/pdt_30.f90 diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index ee39ad8d398..281c29f0a66 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,10 @@ +2019-03-13 Janus Weil + + PR fortran/89601 + * decl.c (gfc_match_formal_arglist): Reject empty type parameter lists. + (gfc_match_derived_decl): Mark as PDT only if type parameter list was + matched successfully. + 2019-03-13 Thomas Koenig PR fortran/66695 diff --git a/gcc/fortran/decl.c b/gcc/fortran/decl.c index 2f335b24835..749faf9fabe 100644 --- a/gcc/fortran/decl.c +++ b/gcc/fortran/decl.c @@ -6275,7 +6275,16 @@ gfc_match_formal_arglist (gfc_symbol *progname, int st_flag, } if (gfc_match_char (')') == MATCH_YES) - goto ok; + { + if (typeparam) + { + gfc_error_now ("A type parameter list is required at %C"); + m = MATCH_ERROR; + goto cleanup; + } + else + goto ok; + } for (;;) { @@ -10217,13 +10226,14 @@ gfc_match_derived_decl (void) m = gfc_match_formal_arglist (sym, 0, 0, true); if (m != MATCH_YES) gfc_error_recovery (); + else + sym->attr.pdt_template = 1; m = gfc_match_eos (); if (m != MATCH_YES) { gfc_error_recovery (); gfc_error_now ("Garbage after PARAMETERIZED TYPE declaration at %C"); } - sym->attr.pdt_template = 1; } if (extended && !sym->components) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 0abb39bdb47..afb61b42d81 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2019-03-13 Janus Weil + + PR fortran/89601 + * gfortran.dg/pdt_16.f03: Modified to avoid follow-up errors. + * gfortran.dg/pdt_30.f90: New test case. + 2019-03-13 Marek Polacek PR c++/88979 - further P0634 fix for constructors. diff --git a/gcc/testsuite/gfortran.dg/pdt_16.f03 b/gcc/testsuite/gfortran.dg/pdt_16.f03 index 067d87d660d..22c6b83a084 100644 --- a/gcc/testsuite/gfortran.dg/pdt_16.f03 +++ b/gcc/testsuite/gfortran.dg/pdt_16.f03 @@ -12,7 +12,6 @@ end program p type t(a ! { dg-error "Expected parameter list" } integer, kind :: a - real(a) :: x end type type u(a, a) ! { dg-error "Duplicate name" } integer, kind :: a ! { dg-error "already declared" } diff --git a/gcc/testsuite/gfortran.dg/pdt_30.f90 b/gcc/testsuite/gfortran.dg/pdt_30.f90 new file mode 100644 index 00000000000..47f7c775465 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pdt_30.f90 @@ -0,0 +1,17 @@ +! { dg-do compile } +! +! PR 89601: [8/9 Regression] [PDT] ICE: Segmentation fault (in resolve_component) +! +! Contributed by Arseny Solokha + +program vw + interface + real function ul (ki) + real :: ki + end function ul + end interface + type :: q8 () ! { dg-error "A type parameter list is required" } + procedure (ul), pointer, nopass :: pj + end type q8 + type (q8) :: ki +end program vw -- 2.30.2