[committed] PR fortran/96085 - ICE in gfc_finish_var_decl, at fortran/trans-decl.c:694

Message ID trinity-258072c1-ea99-459c-8ed4-c046823b6956-1594234628388@3c-app-gmx-bs46
State New
Headers show
Series
  • [committed] PR fortran/96085 - ICE in gfc_finish_var_decl, at fortran/trans-decl.c:694
Related show

Commit Message

Harald Anlauf July 8, 2020, 6:57 p.m.
Committed as obvious.  Check whether the target of a legacy ASSIGN statement
is a parameter and reject if this is the case.

Regtested on x86_64-pc-linux-gnu.

Thanks,
Harald


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.

Patch

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