]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR fortran/34910 (ICE on invalid assignments in doubly-contained functions)
authorPaul Thomas <pault@gcc.gnu.org>
Thu, 31 Jan 2008 22:20:47 +0000 (22:20 +0000)
committerPaul Thomas <pault@gcc.gnu.org>
Thu, 31 Jan 2008 22:20:47 +0000 (22:20 +0000)
2008-01-31  Paul Thomas  <pault@gcc.gnu.org>

PR fortran/34910
* expr.c (gfc_check_assign): It is an error to assign
to a sibling procedure.

2008-01-31  Paul Thomas  <pault@gcc.gnu.org>

PR fortran/34910
* gfortran.dg/proc_assign_2.f90: New test.

From-SVN: r131985

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

index 640681b6ed8f7fab310f1071f704c2da87bc9b78..f426aa240596c250cb5ffa2d069346d76536d6cb 100644 (file)
@@ -1,3 +1,9 @@
+2008-01-31  Paul Thomas  <pault@gcc.gnu.org>
+
+       PR fortran/34910
+       * expr.c (gfc_check_assign): It is an error to assign
+       to a sibling procedure.
+
 2008-01-30  Paul Thomas  <pault@gcc.gnu.org>
 
        PR fortran/34975
index fb1886e94b612d57d85ca642c9c2d4d331c13089..ac159f5ce6ca6fbc518deec6e4ba9b9969e4c92d 100644 (file)
@@ -2705,6 +2705,15 @@ gfc_check_assign (gfc_expr *lvalue, gfc_expr *rvalue, int conform)
            bad_proc = true;
        }
 
+      /* (iv) Host associated and not the function symbol or the
+             parent result.  This picks up sibling references, which
+             cannot be entries.  */
+      if (!sym->attr.entry
+           && sym->ns == gfc_current_ns->parent
+           && sym != gfc_current_ns->proc_name
+           && sym != gfc_current_ns->parent->proc_name->result)
+       bad_proc = true;
+
       if (bad_proc)
        {
          gfc_error ("'%s' at %L is not a VALUE", sym->name, &lvalue->where);
index 2780a74e43d931e12941359b55c4013e1dde25e5..29c8ac9e0af7980fdb4089fdda2f18d00b2d147e 100644 (file)
@@ -1,3 +1,8 @@
+2008-01-31  Paul Thomas  <pault@gcc.gnu.org>
+
+       PR fortran/34910
+       * gfortran.dg/proc_assign_2.f90: New test.
+
 2008-01-31  Douglas Gregor  <doug.gregor@gmail.com>
            Jakub Jelinek  <jakub@redhat.com>
 
diff --git a/gcc/testsuite/gfortran.dg/proc_assign_2.f90 b/gcc/testsuite/gfortran.dg/proc_assign_2.f90
new file mode 100644 (file)
index 0000000..5a92be5
--- /dev/null
@@ -0,0 +1,21 @@
+! { dg-do compile }
+! This checks the fix for PR34910, in which the invalid reference
+! below caused an ICE.
+!
+! Contributed by Daniel Franke <dfranke@gcc.gnu.org>
+!
+MODULE foo
+CONTAINS
+  INTEGER FUNCTION f()
+  f = 42
+  CONTAINS
+    LOGICAL FUNCTION f1()
+      f1 = .TRUE.
+    END FUNCTION
+
+    LOGICAL FUNCTION f2()
+      f1 = .FALSE.  ! { dg-error "not a VALUE" }
+    END FUNCTION
+  END FUNCTION
+END MODULE
+! { dg-final { cleanup-modules "foo" } }