* [PR fortran/57553, patch] - bad error message for invalid use of STORAGE_SIZE
@ 2019-01-22 21:21 Harald Anlauf
2019-01-24 23:13 ` Thomas Koenig
0 siblings, 1 reply; 4+ messages in thread
From: Harald Anlauf @ 2019-01-22 21:21 UTC (permalink / raw)
To: gfortran; +Cc: gcc-patches
[-- Attachment #1: Type: text/plain, Size: 679 bytes --]
The above PR had a partial fix by Tobias Burnus for a valid use of
STORAGE_SIZE, but did not properly handle an error situation.
The attached simple fix adds a list of allowed intrinsics for use
in specification inquiries in F2008+. Testcase by Tobias.
Regtested on x86_64-pc-linux-gnu.
OK for trunk?
Note: I don't have commit rights, so please somebody else take care
of it after review.
Thanks,
Harald
2019-01-22 Harald Anlauf <anlauf@gmx.de>
PR fortran/57553
* expr.c (check_inquiry): Add list of inquiry functions allowed in
constant expressions for F2008+.
2019-01-22 Harald Anlauf <anlauf@gmx.de>
PR fortran/57553
* gfortran.dg/pr57553.f90: New test.
[-- Attachment #2: pr57553.src-patch --]
[-- Type: text/plain, Size: 1357 bytes --]
Index: gcc/fortran/expr.c
===================================================================
--- gcc/fortran/expr.c (revision 268162)
+++ gcc/fortran/expr.c (working copy)
@@ -2515,7 +2515,8 @@
static bool check_restricted (gfc_expr *);
/* F95, 7.1.6.1, Initialization expressions, (7)
- F2003, 7.1.7 Initialization expression, (8) */
+ F2003, 7.1.7 Initialization expression, (8)
+ F2008, 7.1.12 Constant expression, (4)*/
static match
check_inquiry (gfc_expr *e, int not_restricted)
@@ -2539,6 +2540,15 @@
"new_line", NULL
};
+ /* std=f2008+ or -std=gnu */
+ static const char *const inquiry_func_gnu[] = {
+ "lbound", "shape", "size", "ubound",
+ "bit_size", "len", "kind",
+ "digits", "epsilon", "huge", "maxexponent", "minexponent",
+ "precision", "radix", "range", "tiny",
+ "new_line", "storage_size", NULL
+ };
+
int i = 0;
gfc_actual_arglist *ap;
@@ -2565,8 +2575,11 @@
{
name = e->symtree->n.sym->name;
- functions = (gfc_option.warn_std & GFC_STD_F2003)
- ? inquiry_func_f2003 : inquiry_func_f95;
+ functions = inquiry_func_gnu;
+ if (gfc_option.warn_std & GFC_STD_F2003)
+ functions = inquiry_func_f2003;
+ if (gfc_option.warn_std & GFC_STD_F95)
+ functions = inquiry_func_f95;
for (i = 0; functions[i]; i++)
if (strcmp (functions[i], name) == 0)
[-- Attachment #3: pr57553.testcase --]
[-- Type: text/plain, Size: 551 bytes --]
Index: gcc/testsuite/gfortran.dg/pr57553.f90
===================================================================
--- gcc/testsuite/gfortran.dg/pr57553.f90 (nonexistent)
+++ gcc/testsuite/gfortran.dg/pr57553.f90 (working copy)
@@ -0,0 +1,10 @@
+! { dg-do compile }
+!
+! PR fortran/57553 - bad error message for invalid use of STORAGE_SIZE
+!
+! Testcase contributed by Tobias Burnus
+
+subroutine S (A)
+ character(len=*), intent(in) :: A
+ integer, parameter :: ESize = (storage_size(a) + 7) / 8 ! { dg-error "does not reduce to a constant" }
+end
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PR fortran/57553, patch] - bad error message for invalid use of STORAGE_SIZE
2019-01-22 21:21 [PR fortran/57553, patch] - bad error message for invalid use of STORAGE_SIZE Harald Anlauf
@ 2019-01-24 23:13 ` Thomas Koenig
2019-01-26 21:08 ` Harald Anlauf
0 siblings, 1 reply; 4+ messages in thread
From: Thomas Koenig @ 2019-01-24 23:13 UTC (permalink / raw)
To: Harald Anlauf, gfortran; +Cc: gcc-patches
Hi Harald,
> OK for trunk?
OK. Also not likely to cause a regression, so I think this is quite
fine for now.
Regards
Thomas
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PR fortran/57553, patch] - bad error message for invalid use of STORAGE_SIZE
2019-01-24 23:13 ` Thomas Koenig
@ 2019-01-26 21:08 ` Harald Anlauf
2019-01-27 13:19 ` Thomas Koenig
0 siblings, 1 reply; 4+ messages in thread
From: Harald Anlauf @ 2019-01-26 21:08 UTC (permalink / raw)
To: Thomas Koenig; +Cc: gfortran, gcc-patches
Committed as Revision: 268303
URL: https://gcc.gnu.org/viewcvs?rev=268303&root=gcc&view=rev
Log:
2019-01-26 Harald Anlauf <anlauf@gmx.de>
PR fortran/57553
* expr.c (check_inquiry): Add list of inquiry functions allowed in
constant expressions for F2008+.
2019-01-26 Harald Anlauf <anlauf@gmx.de>
PR fortran/57553
* gfortran.dg/pr57553.f90: New test.
Added:
trunk/gcc/testsuite/gfortran.dg/pr57553.f90
Modified:
trunk/gcc/fortran/ChangeLog
trunk/gcc/fortran/expr.c
trunk/gcc/testsuite/ChangeLog
Thanks for the review and support.
Harald
P.S.: this was my first actual commit to gcc.
On 01/24/19 23:28, Thomas Koenig wrote:
> Hi Harald,
>
>> OK for trunk?
>
> OK. Also not likely to cause a regression, so I think this is quite
> fine for now.
>
> Regards
>
> Thomas
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PR fortran/57553, patch] - bad error message for invalid use of STORAGE_SIZE
2019-01-26 21:08 ` Harald Anlauf
@ 2019-01-27 13:19 ` Thomas Koenig
0 siblings, 0 replies; 4+ messages in thread
From: Thomas Koenig @ 2019-01-27 13:19 UTC (permalink / raw)
To: Harald Anlauf; +Cc: gfortran, gcc-patches
Hi Harald,
> P.S.: this was my first actual commit to gcc.
Congratulations, and welcome to the club!
Regards
Thomas
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2019-01-27 12:22 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-22 21:21 [PR fortran/57553, patch] - bad error message for invalid use of STORAGE_SIZE Harald Anlauf
2019-01-24 23:13 ` Thomas Koenig
2019-01-26 21:08 ` Harald Anlauf
2019-01-27 13:19 ` Thomas Koenig
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).