From: Jerry D <jvdelisle2@gmail.com>
To: gfortran <fortran@gcc.gnu.org>
Cc: gcc-patches <gcc-patches@gcc.gnu.org>
Subject: [patch. fortran] PR102595 ICE in var_element, at fortran/decl.c
Date: Fri, 20 Jan 2023 17:46:39 -0800 [thread overview]
Message-ID: <dbce44ba-6020-ee61-d657-5676a5432e79@gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 588 bytes --]
A PARAMETER value is not allowed in a DATA statement, similar to an
EQUIVALENCE.
The check for this was in gfc_assign_data_value() in data.cc which turns
out to be too late when trying to assign a zero sized array.
To correct this, the check is moved to match_variable() in primary.cc
where a similar check for EQUIVALENCE is already being performed.
Regression tested on x86_64-linux-gnu. I will create a test case from
the case presented in the PR which is trivial. There are already two
other tests in the test suite that exercise this check.
OK for trunk?
Regards,
Jerry
[-- Attachment #2: pr102595.diff --]
[-- Type: text/x-patch, Size: 1189 bytes --]
diff --git a/gcc/fortran/data.cc b/gcc/fortran/data.cc
index 443d35da9cf..d29eb12c1b1 100644
--- a/gcc/fortran/data.cc
+++ b/gcc/fortran/data.cc
@@ -244,13 +244,6 @@ gfc_assign_data_value (gfc_expr *lvalue, gfc_expr *rvalue, mpz_t index,
"array-element nor a scalar-structure-component";
symbol = lvalue->symtree->n.sym;
- if (symbol->attr.flavor == FL_PARAMETER)
- {
- gfc_error ("PARAMETER %qs shall not appear in a DATA statement at %L",
- symbol->name, &lvalue->where);
- return false;
- }
-
init = symbol->value;
last_ts = &symbol->ts;
last_con = NULL;
diff --git a/gcc/fortran/primary.cc b/gcc/fortran/primary.cc
index 543d9cc0de4..158f039f225 100644
--- a/gcc/fortran/primary.cc
+++ b/gcc/fortran/primary.cc
@@ -4076,6 +4076,11 @@ match_variable (gfc_expr **result, int equiv_flag, int host_flag)
gfc_error ("Named constant at %C in an EQUIVALENCE");
return MATCH_ERROR;
}
+ if (gfc_in_match_data())
+ {
+ gfc_error ("PARAMETER %qs shall not appear in a DATA statement at %C",
+ sym->name);
+ }
/* Otherwise this is checked for and an error given in the
variable definition context checks. */
break;
next reply other threads:[~2023-01-21 1:46 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-21 1:46 Jerry D [this message]
2023-01-21 5:16 ` Jerry D
2023-01-21 18:27 ` Jerry D
2023-01-21 19:14 ` 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=dbce44ba-6020-ee61-d657-5676a5432e79@gmail.com \
--to=jvdelisle2@gmail.com \
--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).