public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "kargl at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug fortran/107721] Lost typespec with constant expressions using array constructors and parentheses
Date: Fri, 03 Feb 2023 07:07:51 +0000 [thread overview]
Message-ID: <bug-107721-4-J97BkCrRwS@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-107721-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107721
kargl at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |kargl at gcc dot gnu.org
--- Comment #5 from kargl at gcc dot gnu.org ---
(In reply to Jerry DeLisle from comment #4)
>
> print *, ([1.0]) works quite well.
>
> We have, therefore an expr.
>
> In array.cc we have gfc_match_array_constructor. As far as I can tell we
> are matching the ac-implied-do, however we are not even trying to match expr.
>
> Let's see what we can do about it.
>
Yes, it's an expr. The matching happens in gfc_match_array_constructor()
when you get to lines 1311ff
for (;;)
{
m = match_array_cons_element (&head);
if (m == MATCH_ERROR)
goto cleanup;
if (m == MATCH_NO)
goto syntax;
if (gfc_match_char (',') == MATCH_NO)
break;
}
If you deep dive into match_array_cons_element(), you see
m = match_array_list (result);
if (m != MATCH_NO)
return m;
m = gfc_match_expr (&expr);
if (m != MATCH_YES)
return m;
There's your expression mapping. The problem is that for
[integer :: ([1.0])] ** 2, simplification of the expression
([1.0]) returns ([1.0]) and expr_type of EXPR_OP.
So, when we walk the array constructor in lines 1368ff
if (gfc_numeric_ts (&ts))
{
m = walk_array_constructor (&ts, head);
if (m == MATCH_ERROR)
return m;
}
the walker cannot apply a type conversion.
My take is that simplification of ([1.0]) needs to reduce
this to [1.0], which then allows the code to compile. I
had a patch that did this, but it failed with (([1.0])).
I modified the patch to accept (([1.0])), and it of course
failed with ((([1.0]))).
next prev parent reply other threads:[~2023-02-03 7:07 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-16 19:06 [Bug fortran/107721] New: " anlauf at gcc dot gnu.org
2023-01-30 0:26 ` [Bug fortran/107721] " jvdelisle at gcc dot gnu.org
2023-01-30 0:28 ` jvdelisle at gcc dot gnu.org
2023-01-30 0:29 ` jvdelisle at gcc dot gnu.org
2023-02-03 2:34 ` jvdelisle at gcc dot gnu.org
2023-02-03 3:54 ` jvdelisle at gcc dot gnu.org
2023-02-03 7:07 ` kargl at gcc dot gnu.org [this message]
2023-02-04 4:08 ` jvdelisle at gcc dot gnu.org
2023-02-04 16:45 ` jvdelisle at gcc dot gnu.org
2023-02-20 23:46 ` jvdelisle at gcc dot gnu.org
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=bug-107721-4-J97BkCrRwS@http.gcc.gnu.org/bugzilla/ \
--to=gcc-bugzilla@gcc.gnu.org \
--cc=gcc-bugs@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).