PR fortran/96085 - ICE in gfc_finish_var_decl, at fortran/trans-decl.c:694
authorHarald Anlauf <anlauf@gmx.de>
Wed, 8 Jul 2020 18:53:12 +0000 (20:53 +0200)
committerHarald Anlauf <anlauf@gmx.de>
Wed, 8 Jul 2020 18:53:12 +0000 (20:53 +0200)
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
gcc/testsuite/gfortran.dg/pr96085.f90 [new file with mode: 0644]

index 223dcccce9114a2dde15f96361c755e239351781..6bc1c46a97dcbec28ca5f308a968ce7dc0b6b9ab 100644 (file)
@@ -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 (file)
index 0000000..82b1cde
--- /dev/null
@@ -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