From: Steve Kargl <sgk@troutmask.apl.washington.edu>
To: Harald Anlauf <anlauf@gmx.de>
Cc: fortran <fortran@gcc.gnu.org>, gcc-patches <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH] Fortran: restrictions on integer arguments to SYSTEM_CLOCK [PR112609]
Date: Sat, 18 Nov 2023 16:04:09 -0800 [thread overview]
Message-ID: <ZVlQ-Yzmr4KFTeTM@troutmask.apl.washington.edu> (raw)
In-Reply-To: <trinity-2e24bb1a-a94a-4a96-b684-1aaf2879485b-1700345575361@3c-app-gmx-bs41>
On Sat, Nov 18, 2023 at 11:12:55PM +0100, Harald Anlauf wrote:
>
> Fortran 2023 added restrictions on integer arguments to SYSTEM_CLOCK.
> The attached patch implements these.
>
> I was struggling with the way we should handle features that are sort-of
> deleted in a new standard, but not described as such in the standard,
> which is why we do not have GFC_STD_F2023_DEL. As -std=gnu should not
> apply this restriction, I came up with the solution in the patch.
> While playing, I hit a gcc_unreachable in notify_std_msg due to a
> missing case, also fixed.
>
> Interestingly, the standard now has a recommendation:
>
> 16.9.202 SYSTEM_CLOCK
>
> It it recommended that all references to SYSTEM_CLOCK use integer
> arguments with a decimal exponent range of at least 18. ...
>
> In case the user chooses integer(4), shall we emit a warning
> e.g. under -pedantic, or some other flag? This is not done
> in the patch, but could be added.
>
> Regtested on x86_64-pc-linux-gnu. OK for mainline?
>
Not in its current form.
> {
> + int first_int_kind = -1;
> + bool f2023 = ((gfc_option.allow_std & GFC_STD_F2023) != 0
> + && (gfc_option.allow_std & GFC_STD_GNU) == 0);
> +
If you use the gfc_notify_std(), then you should not need the
above check on GFC_STD_GNU as it should include GFC_STD_F2023.
>
> + if (f2023 && count->ts.kind < gfc_default_integer_kind)
> + {
> + gfc_error ("Fortran 2023: COUNT argument to SYSTEM_CLOCK "
> + "at %L must have kind of at least default integer",
> + &count->where);
> + return false;
> + }
Elsewhere in the FE, gfortran uses gfc_notify_std() to enforce
requirements of a Fortran standard. The above would be
if (count->ts.kind < gfc_default_integer_kind
&& gfc_notify_std (GFC_STD_F2023, "COUNT argument to SYSTEM_CLOCK "
"at %L must have kind of at least default integer",
&count->where))
Note, gfc_notify_std() should add the 'Fortran 2023: ' string,
if not, that should be fixed.
Of course, I seldom provide patches if others don't have a comment
then do as you like.
--
Steve
next prev parent reply other threads:[~2023-11-19 0:04 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-18 22:12 Harald Anlauf
2023-11-19 0:04 ` Steve Kargl [this message]
2023-11-19 20:46 ` [PATCH, v2] " Harald Anlauf
2023-11-20 19:02 ` Steve Kargl
2023-11-21 11:33 ` Mikael Morin
2023-11-21 21:54 ` [PATCH, v3] " Harald Anlauf
2023-11-21 22:09 ` Harald Anlauf
2023-11-22 9:36 ` Mikael Morin
2023-11-22 18:03 ` Steve Kargl
2023-11-22 20:40 ` Harald Anlauf
2023-11-22 20:40 ` Harald Anlauf
2023-11-22 20:36 ` [PATCH, v4] " Harald Anlauf
2023-11-23 9:07 ` Mikael Morin
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=ZVlQ-Yzmr4KFTeTM@troutmask.apl.washington.edu \
--to=sgk@troutmask.apl.washington.edu \
--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).