From 1fa08dcac686ca5b6d84e64c9f5813daef59f540 Mon Sep 17 00:00:00 2001 From: Harald Anlauf Date: Wed, 8 Jul 2020 20:53:12 +0200 Subject: [PATCH] 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. --- gcc/fortran/resolve.c | 1 + gcc/testsuite/gfortran.dg/pr96085.f90 | 12 ++++++++++++ 2 files changed, 13 insertions(+) create mode 100644 gcc/testsuite/gfortran.dg/pr96085.f90 diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c index 223dcccce91..6bc1c46a97d 100644 --- a/gcc/fortran/resolve.c +++ b/gcc/fortran/resolve.c @@ -11900,6 +11900,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); diff --git a/gcc/testsuite/gfortran.dg/pr96085.f90 b/gcc/testsuite/gfortran.dg/pr96085.f90 new file mode 100644 index 00000000000..82b1cdec0f6 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr96085.f90 @@ -0,0 +1,12 @@ +! { dg-do compile } +! { dg-options "-std=legacy" } +! PR fortran/96085 - ICE in gfc_finish_var_decl, at fortran/trans-decl.c:694 + +module m + integer, parameter :: a = 1 +contains + subroutine s + assign 2 to a ! { dg-error "requires a scalar default INTEGER variable" } +2 print *, a + end +end -- 2.30.2