Hi Steve, > > Technically the ICE is a regression, but since it happens on invalid > > code only, backporting is not essential IMHO (but might still be > > useful). Ok for trunk? And 8-branch? > > Looks good to me with a minor suggestion. See below.
thanks for the comments. Updated patch attached. > You may want to wait a bit or ping Paul to give him > a chance to peek at the patch. I'm putting Paul in CC and will wait until tomorrow night before committing. > > if (gfc_match_char (')') == MATCH_YES) > > - goto ok; > > + { > > + if (typeparam) > > + { > > + gfc_error_now ("A parameter name is required at %C"); > > Can you insert "type" so the error reads "A type parameter name"? > Unfortunately, the words parameter has a few too many meanings. True. I'm using 'type parameter list' now. Cheers, Janus
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index a3b47ac4980..834c73fc27e 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,10 @@ +2019-03-12 Janus Weil <ja...@gcc.gnu.org> + + 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-11 Jakub Jelinek <ja...@redhat.com> PR fortran/89651 diff --git a/gcc/fortran/decl.c b/gcc/fortran/decl.c index a29e2db0bd6..3ebce880b39 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 9b20bdfe787..8c8d282491b 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2019-03-12 Janus Weil <ja...@gcc.gnu.org> + + PR fortran/89601 + * gfortran.dg/pdt_16.f03: Modified to avoid follow-up errors. + * gfortran.dg/pdt_30.f90: New test case. + 2019-03-12 Jakub Jelinek <ja...@redhat.com> PR middle-end/89663 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 <asolo...@gmx.com> + +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