Affects versions down to at least r5 : $ cat z1.f90 module m integer, parameter :: a = 1 contains subroutine s assign 2 to a 2 print *, a end end $ cat z2.f90 subroutine sub integer, parameter :: a = 1 call s contains subroutine s assign 2 to a 2 print *, a end end $ gfortran-11-20200705 -c z2.f90 # accepts invalid z2.f90:5:19: 6 | assign 2 to a | 1 Warning: Deleted feature: ASSIGN statement at (1) $ gfortran-11-20200705 -c z1.f90 z1.f90:5:19: 5 | assign 2 to a | 1 Warning: Deleted feature: ASSIGN statement at (1) z1.f90:5:0: 5 | assign 2 to a | internal compiler error: in gfc_finish_var_decl, at fortran/trans-decl.c:694 0x72c269 gfc_finish_var_decl ../../gcc/fortran/trans-decl.c:694 0x72b5c1 gfc_get_symbol_decl(gfc_symbol*) ../../gcc/fortran/trans-decl.c:1852 0x73a4b8 gfc_conv_variable ../../gcc/fortran/trans-expr.c:2735 0x7366ca gfc_conv_expr(gfc_se*, gfc_expr*) ../../gcc/fortran/trans-expr.c:8693 0x775a36 gfc_conv_label_variable(gfc_se*, gfc_expr*) ../../gcc/fortran/trans-stmt.c:80 0x775aac gfc_trans_label_assign(gfc_code*) ../../gcc/fortran/trans-stmt.c:104 0x705d97 trans_code ../../gcc/fortran/trans.c:1868 0x72f324 gfc_generate_function_code(gfc_namespace*) ../../gcc/fortran/trans-decl.c:6840 0x709c49 gfc_generate_module_code(gfc_namespace*) ../../gcc/fortran/trans.c:2264 0x6b6901 translate_all_program_units ../../gcc/fortran/parse.c:6294 0x6b6901 gfc_parse_file() ../../gcc/fortran/parse.c:6546 0x70284f gfc_be_parse_file ../../gcc/fortran/f95-lang.c:212
Confirmed.
Patch: diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c index 223dcccce91..8eba7c95b4a 100644 --- a/gcc/fortran/resolve.c +++ b/gcc/fortran/resolve.c @@ -11900,6 +11902,7 @@ start: || code->expr1->symtree->n.sym->ts.type != BT_INTEGER || code->expr1->symtree->n.sym->ts.kind != gfc_default_integer_kind + || code->expr1->symtree->n.sym->attr.flavor != FL_VARIABLE || code->expr1->symtree->n.sym->as != NULL)) gfc_error ("ASSIGN statement at %L requires a scalar " "default INTEGER variable", &code->expr1->where);
(In reply to anlauf from comment #2) That one produces a strange regression with pr50392.f. Patch that regtests fine: diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c index 223dcccce91..c88b76a232a 100644 --- a/gcc/fortran/resolve.c +++ b/gcc/fortran/resolve.c @@ -11900,6 +11902,7 @@ start: || code->expr1->symtree->n.sym->ts.type != BT_INTEGER || code->expr1->symtree->n.sym->ts.kind != gfc_default_integer_kind + || code->expr1->symtree->n.sym->attr.flavor == FL_PARAMETER || code->expr1->symtree->n.sym->as != NULL)) gfc_error ("ASSIGN statement at %L requires a scalar " "default INTEGER variable", &code->expr1->where);
The master branch has been updated by Harald Anlauf <anlauf@gcc.gnu.org>: https://gcc.gnu.org/g:1fa08dcac686ca5b6d84e64c9f5813daef59f540 commit r11-1949-g1fa08dcac686ca5b6d84e64c9f5813daef59f540 Author: Harald Anlauf <anlauf@gmx.de> Date: Wed Jul 8 20:53:12 2020 +0200 PR fortran/96085 - ICE in gfc_finish_var_decl, at fortran/trans-decl.c:694 Legacy ASSIGN requires a scalar integer variable. Reject parameter arguments. gcc/fortran/ PR fortran/96085 * resolve.c (gfc_resolve_code): Check whether assign target is a parameter.
Fixed on master for gcc-11. Thanks for the report!