https://gcc.gnu.org/bugzilla/show_bug.cgi?id=57553
Harald Anlauf <anlauf at gmx dot de> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |anlauf at gmx dot de
--- Comment #5 from Harald Anlauf <anlauf at gmx dot de> ---
(In reply to Tobias Burnus from comment #3)
> The rejects-valid and the ICE-on-valid-code issue has been solved.
>
>
> TODO: The following message for invalid code should be improved. [The
> problem is that storage_size cannot handle "a", which is required for a
> constant expression.]
>
> integer, parameter :: ESize = ( storage_size(a) + 7 ) / 8
> 1
> Error: Unclassifiable statement at (1)
It appears that check_inquiry() does not recognize storage_size
as an intrinsic.
The patch below turns the error message (for -std=gnu/f2008) into:
pr57553.f90:4:45:
integer, parameter :: ESize = storage_size(a)
1
Error: Parameter 'a' at (1) has not been declared or is a variable, which does
not reduce to a constant expression
Index: gcc/fortran/expr.c
===================================================================
--- gcc/fortran/expr.c (revision 233203)
+++ gcc/fortran/expr.c (working copy)
@@ -2264,6 +2264,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;
@@ -2290,8 +2299,11 @@
{
name = e->symtree->n.sym->name;
+ functions = inquiry_func_gnu; /* std=f2008+ or -std=gnu */
functions = (gfc_option.warn_std & GFC_STD_F2003)
- ? inquiry_func_f2003 : inquiry_func_f95;
+ ? inquiry_func_f2003 : functions;
+ functions = (gfc_option.warn_std & GFC_STD_F95)
+ ? inquiry_func_f95 : functions;
for (i = 0; functions[i]; i++)
if (strcmp (functions[i], name) == 0)