diff mbox series

[fortran,committed] Error on Associate with a program

Message ID a286b83e-a3a2-1c87-92f6-45e799b47549@tkoenig.net
State New
Headers show
Series [fortran,committed] Error on Associate with a program | expand

Commit Message

Thomas König Dec. 8, 2019, 1:43 p.m. UTC
Hello world,

yet another obvious and simple fix:  You cannot really associate
the main program with a variable.  Committed as r279088 after
regression-testing.

Regards

	Thomas


2018-12-08  Thomas Koenig  <tkoenig@gcc.gnu.org>

	PR fortran/92780
	* resolve.c (resolve_assoc_var): Issue error if the associating
	entity is a program.

2018-12-08  Thomas Koenig  <tkoenig@gcc.gnu.org>

	PR fortran/92780
	* gfortran.dg/associate_50.f90: New test.
diff mbox series

Patch

Index: resolve.c
===================================================================
--- resolve.c	(Revision 279064)
+++ resolve.c	(Arbeitskopie)
@@ -8842,6 +8842,12 @@  resolve_assoc_var (gfc_symbol* sym, bool resolve_t
 
       gcc_assert (target->symtree);
       tsym = target->symtree->n.sym;
+      if (tsym->attr.flavor == FL_PROGRAM)
+	{
+	  gfc_error ("Associating entity %qs at %L is a PROGRAM",
+		     tsym->name, &target->where);
+	  return;
+	}
 
       sym->attr.asynchronous = tsym->attr.asynchronous;
       sym->attr.volatile_ = tsym->attr.volatile_;