public inbox for fortran@gcc.gnu.org
 help / color / mirror / Atom feed
From: Mikael Morin <morin-mikael@orange.fr>
To: Harald Anlauf <anlauf@gmx.de>, fortran@gcc.gnu.org
Cc: gcc-patches@gcc.gnu.org
Subject: Re: [PATCH, v3] Fortran: detect blanks within literal constants in free-form mode [PR92805]
Date: Sat, 30 Jul 2022 10:28:19 +0200	[thread overview]
Message-ID: <b7a18d4f-f9a6-4c19-5c6f-884e654e60f5@orange.fr> (raw)
In-Reply-To: <fc72cd92-3f37-6d0f-30ac-0d93584524e4@gmx.de>

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.

  parent reply	other threads:[~2022-07-30  8:28 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-28 20:11 [PATCH] " Harald Anlauf
2022-07-29 11:11 ` Mikael Morin
2022-07-29 19:59   ` [PATCH, v2] " Harald Anlauf
2022-07-29 19:59     ` Harald Anlauf
2022-07-29 20:36     ` Mikael Morin
2022-07-29 21:09       ` [PATCH, v3] " Harald Anlauf
2022-07-29 21:09         ` Harald Anlauf
2022-07-30  7:46         ` Thomas Koenig
2022-07-30 18:32           ` Harald Anlauf
2022-07-30 18:32             ` Harald Anlauf
2022-07-30  8:28         ` Mikael Morin [this message]
2022-07-30 19:40           ` [PATCH, v4] " Harald Anlauf
2022-07-31  8:35             ` Mikael Morin
2022-07-31 19:01               ` Harald Anlauf
2022-07-31 19:01                 ` Harald Anlauf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b7a18d4f-f9a6-4c19-5c6f-884e654e60f5@orange.fr \
    --to=morin-mikael@orange.fr \
    --cc=anlauf@gmx.de \
    --cc=fortran@gcc.gnu.org \
    --cc=gcc-patches@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).