[Bug fortran/96038] New: Confirming implicitly type parameter causes an invalid error
kargl at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Thu Jul 2 19:48:45 GMT 2020
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96038
Bug ID: 96038
Summary: Confirming implicitly type parameter causes an invalid
error
Product: gcc
Version: 10.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
Assignee: unassigned at gcc dot gnu.org
Reporter: kargl at gcc dot gnu.org
Target Milestone: ---
Consider the following fixed-form source code:
function ifoo()
parameter (n = 50)
integer n
ifoo = n
end
Everything is implicitly type. Gfortran gives
function ifoo()
parameter (n = 50)
integer n
ifoo = n
end
% gfortran -c a.f
a.f:3:15:
3 | integer n
| 1
Error: PARAMETER at (1) is missing an initializer
which is wrong. The code should compile as an implicitly type
entity can appear in a declaration statement if that declaration
statement confirms the implicit type.
The patch is straight forward. This is against svn revision 280156.
The patch has not been regression tested.
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)
More information about the Gcc-bugs
mailing list