PR fortran/49278 - ICE when combining DATA with default initialization
A variable with the PARAMETER attribute may not appear in a DATA statement. gcc/fortran/ChangeLog: PR fortran/49278 * data.c (gfc_assign_data_value): Reject variable with PARAMETER attribute in DATA statement. gcc/testsuite/ChangeLog: PR fortran/49278 * gfortran.dg/parameter_data.f90: New test.
This commit is contained in:
parent
f3daa6c0fd
commit
bd85b4dd2d
@ -244,6 +244,13 @@ gfc_assign_data_value (gfc_expr *lvalue, gfc_expr *rvalue, mpz_t index,
|
||||
"array-element nor a scalar-structure-component";
|
||||
|
||||
symbol = lvalue->symtree->n.sym;
|
||||
if (symbol->attr.flavor == FL_PARAMETER)
|
||||
{
|
||||
gfc_error ("PARAMETER %qs shall not appear in a DATA statement at %L",
|
||||
symbol->name, &lvalue->where);
|
||||
return false;
|
||||
}
|
||||
|
||||
init = symbol->value;
|
||||
last_ts = &symbol->ts;
|
||||
last_con = NULL;
|
||||
|
13
gcc/testsuite/gfortran.dg/parameter_data.f90
Normal file
13
gcc/testsuite/gfortran.dg/parameter_data.f90
Normal file
@ -0,0 +1,13 @@
|
||||
! { dg-do compile }
|
||||
! PR fortran/49278 - ICE when combining DATA with default initialization
|
||||
|
||||
program p
|
||||
implicit none
|
||||
type t
|
||||
real :: a
|
||||
end type t
|
||||
integer, parameter :: b = 42
|
||||
type(t), parameter :: z = t(4.0)
|
||||
data b / 666 / ! { dg-error "shall not appear in a DATA statement" }
|
||||
data z%a / 3.0 / ! { dg-error "shall not appear in a DATA statement" }
|
||||
end
|
Loading…
Reference in New Issue
Block a user