From: Steve Kargl <sgk@troutmask.apl.washington.edu>
To: Steve Kargl via Fortran <fortran@gcc.gnu.org>
Subject: Re: typespec in forall and implied-do
Date: Wed, 16 Nov 2022 12:24:25 -0800 [thread overview]
Message-ID: <Y3VG+SAwqKIUpnCZ@troutmask.apl.washington.edu> (raw)
In-Reply-To: <Y3RLdLsomI8+MobE@troutmask.apl.washington.edu>
On Tue, Nov 15, 2022 at 06:31:16PM -0800, Steve Kargl via Fortran wrote:
> On Tue, Nov 15, 2022 at 05:13:19PM -0800, Steve Kargl via Fortran wrote:
> > F2008 introduced the inclusion of a typespec in a forall
> > statement, and thn F2018 a typespec was allowed in an
> > implied-do. There may even be a few bug reports.
> >
>
> Forgot to ask. Anyone know how namespaces work with
> initialization expressions in gfortran? This code
> should compile
>
> program foo
> use iso_fortran_env, only : k => real_kinds
> implicit none
> integer, parameter :: n = size(k)
> integer, parameter :: &
> & p(n) = [(precision(real(1.,k(i))), integer :: i = 1, n)]
> print '(*(I0,X))', p
> end program foo
>
>
> The first occurence of 'i' in the expression for 'p(n)'
> is either thought to be in a different namespace, or
> an implied-do loop cannot be used in an initialization
> expression.
After spending to much time on this, I found that decl.cc:3044-50
m = gfc_match_init_expr (&initializer);
if (m == MATCH_NO)
{
gfc_error ("Expected an initialization expression at %C");
m = MATCH_ERROR;
}
results in m == MATCH_ERROR. First, I would expect the "if"
condition to include the m == MATCH_ERROR to generate an
error message. Second, an implied-do loop can appear in
an initialization expression. So, gfortran is not handling
this correctly. Now, if one goes to expr.cc:gfc_match_init_expr,
gfortran matches the RHS expression, but gfc_reduce_init_expr()
fails to expand the array constructor.
--
Steve
next prev parent reply other threads:[~2022-11-16 20:24 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-16 1:13 Steve Kargl
2022-11-16 2:31 ` Steve Kargl
2022-11-16 20:24 ` Steve Kargl [this message]
2022-11-16 18:08 ` Steve Kargl
2022-11-16 18:20 ` Steve Kargl
2022-11-16 21:30 ` Steve Kargl
2022-11-17 0:32 ` Steve Kargl
2022-11-17 0:47 ` Steve Kargl
2022-11-17 4:15 ` Steve Kargl
2022-11-17 18:48 ` Steve Kargl
2022-11-20 21:28 Harald Anlauf
2022-11-20 23:31 ` Steve Kargl
[not found] ` <d2efcc09-f5be-904e-fb70-f75fdabbee1f@orange.fr>
[not found] ` <Y3vHlojilLVU8qC2@troutmask.apl.washington.edu>
2022-11-27 19:17 ` Mikael Morin
2022-11-27 19:33 ` Mikael Morin
2022-11-20 23:33 ` Steve Kargl
2022-11-22 21:15 ` Harald Anlauf
2022-11-22 21:59 ` Steve Kargl
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=Y3VG+SAwqKIUpnCZ@troutmask.apl.washington.edu \
--to=sgk@troutmask.apl.washington.edu \
--cc=fortran@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).