Le 29/07/2022 à 23:09, Harald Anlauf via Fortran a écrit :
Hi Mikael,

Am 29.07.22 um 22:36 schrieb Mikael Morin:
Indeed, I overlooked that, but my opinion remains that we shouldn’t play with fixed vs free form considerations here.
So the options I can see are:
  - handle the locus in get_kind; we do it a lot already in matching functions, so it wouldn’t be different here.
  - implement a variant of gfc_match_char without space gobbling.
  - use gfc_match(...), which is a bit heavy weight to match a single char string, but otherwise would keep things concise.

My preference goes to the third option, but I’m fine with either of them if you have a different one.


how about the attached?

This introduces the helper function gfc_match_next_char, which is
your second option.

diff --git a/gcc/fortran/primary.cc b/gcc/fortran/primary.cc
index 3f01f67cd49..9fa6779200f 100644
--- a/gcc/fortran/primary.cc
+++ b/gcc/fortran/primary.cc
@@ -92,14 +92,17 @@ get_kind (int *is_iso_c)
 {
   int kind;
   match m;
+  char c;
*is_iso_c = 0; - if (gfc_match_char ('_') != MATCH_YES)
+  if (gfc_match_next_char ('_') != MATCH_YES)
     return -2;
- m = match_kind_param (&kind, is_iso_c);
-  if (m == MATCH_NO)
+  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");
Meh! We killed one check for gfc_current_form but the other one is still there. OK, match_kind_param calls two functions that also gobble space, so there is work remaining here. So please make match_small_literal_constant and gfc_match_name space-gobbling wrappers around space-non-gobbling inner functions and call those inner functions instead in match_kind_param.

Reply via email to