mirror of
git://gcc.gnu.org/git/gcc.git
synced 2025-03-21 23:00:52 +08:00
Fortran : Implicitly type parameter causes an invalid error PR96038
If a paramter to declared and initialised before its type is declared a bogus error is output at the type declaration idicating that initialisation is missing. 2020-07-14 Steven G. Kargl <kargl@gcc.gnu.org> gcc/fortran/ PR fortran/96038 * decl.c (add_init_expr_sym): For a symbol that is a parameter accept an initialisation if it does not have a value otherwise output a error and reject. 2020-07-14 Mark Eggleston <markeggleston@gcc.gnu.org> gcc/testsuite/ PR fortran/96038 * gfortran.dg/pr96038.f90: New test.
This commit is contained in:
parent
ea69fcf9a0
commit
9ad19a66d7
@ -1889,13 +1889,16 @@ add_init_expr_to_sym (const char *name, gfc_expr **initp, locus *var_locus)
|
||||
|
||||
/* 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)
|
||||
|
8
gcc/testsuite/gfortran.dg/pr96038.f90
Normal file
8
gcc/testsuite/gfortran.dg/pr96038.f90
Normal file
@ -0,0 +1,8 @@
|
||||
! { dg-do compile }
|
||||
|
||||
function ifoo()
|
||||
parameter (n = 50)
|
||||
integer n
|
||||
ifoo = n
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user