https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92805

--- Comment #4 from Steve Kargl <sgk at troutmask dot apl.washington.edu> ---
On Fri, Dec 06, 2019 at 06:48:04PM +0000, kargl at gcc dot gnu.org wrote:
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92805
> 
> --- Comment #3 from kargl at gcc dot gnu.org ---
> (In reply to kargl from comment #2)
> > Index: gcc/fortran/primary.c
> > ===================================================================
> > --- gcc/fortran/primary.c   (revision 279052)
> > +++ gcc/fortran/primary.c   (working copy)
> > @@ -90,16 +90,25 @@ match_kind_param (int *kind, int *is_iso_c)
> >  static int
> >  get_kind (int *is_iso_c)
> >  {
> > +  char c;
> >    int kind;
> >    match m;
> >  
> >    *is_iso_c = 0;
> >  
> > +  c = gfc_peek_ascii_char ();
> > +  if (gfc_current_form == FORM_FREE && gfc_is_whitespace (c))
> > +    {
> > +      gfc_error ("Invalid kind type parameter syntax at %C");
> > +      return -1;
> > +    }
> > +
> >    if (gfc_match_char ('_') != MATCH_YES)
> >      return -2;
> >  
> > -  m = match_kind_param (&kind, is_iso_c);
> > -  if (m == MATCH_NO)
> > +  c = gfc_peek_ascii_char ();
> > +  if ((gfc_current_form == FORM_FREE && gfc_is_whitespace (c))
> > +      || (m = match_kind_param (&kind, is_iso_c)) == MATCH_NO)
> >      gfc_error ("Missing kind-parameter at %C");
> >  
> >    return (m == MATCH_YES) ? kind : -1;
> 
> Patch isn't quite correct.  The first gfc_error should probably be removed and
> return -2.
> 

Tested.

Index: gcc/fortran/primary.c
===================================================================
--- gcc/fortran/primary.c       (revision 279052)
+++ gcc/fortran/primary.c       (working copy)
@@ -90,16 +90,22 @@ match_kind_param (int *kind, int *is_iso_c)
 static int
 get_kind (int *is_iso_c)
 {
+  char c;
   int kind;
   match m;

   *is_iso_c = 0;

+  c = gfc_peek_ascii_char ();
+  if (gfc_current_form == FORM_FREE && gfc_is_whitespace (c))
+    return -2;
+
   if (gfc_match_char ('_') != MATCH_YES)
     return -2;

-  m = match_kind_param (&kind, is_iso_c);
-  if (m == MATCH_NO)
+  c = gfc_peek_ascii_char ();
+  if ((gfc_current_form == FORM_FREE && gfc_is_whitespace (c))
+      || (m = match_kind_param (&kind, is_iso_c)) == MATCH_NO)
     gfc_error ("Missing kind-parameter at %C");

   return (m == MATCH_YES) ? kind : -1;

Reply via email to