https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96033
--- Comment #9 from Steve Kargl <sgk at troutmask dot apl.washington.edu> ---
On Thu, Jul 02, 2020 at 06:30:40PM +0000, sgk at troutmask dot
apl.washington.edu wrote:
>
> It isn't a matter of simply switching rules. It's a matter of bugs
> and whether the bug is reported. In the small snippet you posted,
> there is clearly a problem with implicit typing and parameter statements.
> This compiles
>
> function jfoo()
> parameter (MSHLNG=50)
> jfoo = mshlng
> end
>
> and this doesn't
>
> function ifoo()
> parameter (MSHLNG=50)
> integer MSHLNG
> ifoo = mshlng
> end
>
> % gfcx -c a.f
> a.f:3:22:
>
> 3 | integer MSHLNG
> | 1
> Error: PARAMETER at (1) is missing an initializer
>
> The Fortran standard has
>
> If a named constant is defined by a PARAMETER statement, it shall
> not be subsequently declared to have a type or type parameter value
> that differs from the type and type parameters it would have if
> declared implicitly (8.7).
>
> What is puzzling is that the 'parameter (mshlng=50)' is
> correctly parsed. The declaration statement is incorrectly
> parsed, but I don't know why, yet.
>
When bugs are reported, they sometime get fixed.
(Copy-n-paste tab corruption in patch)
Index: gcc/fortran/decl.c
===================================================================
--- gcc/fortran/decl.c (revision 280157)
+++ gcc/fortran/decl.c (working copy)
@@ -1864,13 +1864,16 @@ add_init_expr_to_sym (const char *name, gfc_expr **ini
/* If this symbol is confirming an implicit parameter type,
then an initialization expression is not allowed. */
- if (attr.flavor == FL_PARAMETER
- && sym->value != NULL
- && *initp != NULL)
+ if (attr.flavor == FL_PARAMETER && sym->value != NULL)
{
- gfc_error ("Initializer not allowed for PARAMETER %qs at %C",
- sym->name);
- return false;
+ if (*initp != NULL)
+ {
+ gfc_error ("Initializer not allowed for PARAMETER %qs at %C",
+ sym->name);
+ return false;
+ }
+ else
+ return true;
}
if (init == NULL)