Error on Associate with a program.
authorThomas Koenig <tkoenig@gcc.gnu.org>
Sun, 8 Dec 2019 13:42:42 +0000 (13:42 +0000)
committerThomas Koenig <tkoenig@gcc.gnu.org>
Sun, 8 Dec 2019 13:42:42 +0000 (13:42 +0000)
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.

From-SVN: r279088

gcc/fortran/ChangeLog
gcc/fortran/resolve.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/associate_50.f90 [new file with mode: 0644]

index 5265c2c3794b1ab28bfc45092d5483972a22a0b1..c3a4c3adcdb7b5cddf81b13ae8f64a3fa1f5ba09 100644 (file)
@@ -1,3 +1,9 @@
+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/92764
index 278dad363fd0c776295fd964c085317b54f95131..b437c59550074b23e2f664e33a35dc833dc646e1 100644 (file)
@@ -8842,6 +8842,12 @@ resolve_assoc_var (gfc_symbol* sym, bool resolve_target)
 
       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_;
index d2f9b47a3b6ccbf90eb1e8e33b32e7037280fd24..8e8e1e9b5320a1814567b4e618a8dfaa67946642 100644 (file)
@@ -1,3 +1,8 @@
+2018-12-08  Thomas Koenig  <tkoenig@gcc.gnu.org>
+
+       PR fortran/92780
+       * gfortran.dg/associate_50.f90: New test.
+
 2018-12-08  Thomas Koenig  <tkoenig@gcc.gnu.org>
 
        PR fortran/92764
diff --git a/gcc/testsuite/gfortran.dg/associate_50.f90 b/gcc/testsuite/gfortran.dg/associate_50.f90
new file mode 100644 (file)
index 0000000..d759db5
--- /dev/null
@@ -0,0 +1,8 @@
+! { dg-do compile }
+! PR 92780 - this used to ICE instead of being rejected.
+! Test case by Gerhard Steinmetz.
+
+program p
+  associate (y => p) ! { dg-error "is a PROGRAM" }
+  end associate
+end program p