aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorPaul Thomas <pault@gcc.gnu.org>2008-01-31 22:20:47 +0000
committerPaul Thomas <pault@gcc.gnu.org>2008-01-31 22:20:47 +0000
commitdb39d0c23d152eb9ce816dbb59bae15c19cc46aa (patch)
tree827d843af0d30a8bc85669854afa7db71d97e61c /gcc
parent0451301c5987ec736e4e7c8a2f430b3b9051288e (diff)
downloadgcc-db39d0c23d152eb9ce816dbb59bae15c19cc46aa.zip
gcc-db39d0c23d152eb9ce816dbb59bae15c19cc46aa.tar.gz
gcc-db39d0c23d152eb9ce816dbb59bae15c19cc46aa.tar.bz2
re PR fortran/34910 (ICE on invalid assignments in doubly-contained functions)
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
Diffstat (limited to 'gcc')
-rw-r--r--gcc/fortran/ChangeLog6
-rw-r--r--gcc/fortran/expr.c9
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gfortran.dg/proc_assign_2.f9021
4 files changed, 41 insertions, 0 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index 640681b..f426aa2 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -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
diff --git a/gcc/fortran/expr.c b/gcc/fortran/expr.c
index fb1886e..ac159f5 100644
--- a/gcc/fortran/expr.c
+++ b/gcc/fortran/expr.c
@@ -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);
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 2780a74..29c8ac9 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -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
index 0000000..5a92be5
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/proc_assign_2.f90
@@ -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" } }