summaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorpault <pault@138bc75d-0d04-0410-961f-82ee72b054a4>2007-04-05 14:00:27 +0000
committerpault <pault@138bc75d-0d04-0410-961f-82ee72b054a4>2007-04-05 14:00:27 +0000
commit63d42079052fc1cdcb30a3e1b8db54a4de3ad3f1 (patch)
treedf13ebdde93460ad65add194cc1c5525e7975da8 /gcc
parent9f525417fc43096dbb5b2278af260e9b88098e80 (diff)
downloadgcc-63d42079052fc1cdcb30a3e1b8db54a4de3ad3f1.tar.gz
2007-04-05 Paul Thomas <pault@gcc.gnu.org>
PR fortran/31292 * decl.c (gfc_match_modproc): Go up to the top of the namespace tree to find the module namespace for gfc_get_symbol. 2007-04-05 Paul Thomas <pault@gcc.gnu.org> PR fortran/31292 * gfortran.dg/contained_module_proc_1.f90: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@123517 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc')
-rw-r--r--gcc/fortran/ChangeLog6
-rw-r--r--gcc/fortran/decl.c11
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gfortran.dg/contained_module_proc_1.f9040
4 files changed, 61 insertions, 1 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index f43ac735215..6e1be68f416 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,3 +1,9 @@
+2007-04-05 Paul Thomas <pault@gcc.gnu.org>
+
+ PR fortran/31292
+ * decl.c (gfc_match_modproc): Go up to the top of the namespace
+ tree to find the module namespace for gfc_get_symbol.
+
2007-04-03 Francois-Xavier Coudert <fxcoudert@gcc.gnu.org>
PR fortran/31304
diff --git a/gcc/fortran/decl.c b/gcc/fortran/decl.c
index 570a036c041..c9383ccce69 100644
--- a/gcc/fortran/decl.c
+++ b/gcc/fortran/decl.c
@@ -4241,6 +4241,7 @@ gfc_match_modproc (void)
char name[GFC_MAX_SYMBOL_LEN + 1];
gfc_symbol *sym;
match m;
+ gfc_namespace *module_ns;
if (gfc_state_stack->state != COMP_INTERFACE
|| gfc_state_stack->previous == NULL
@@ -4251,6 +4252,14 @@ gfc_match_modproc (void)
return MATCH_ERROR;
}
+ module_ns = gfc_current_ns->parent;
+ for (; module_ns; module_ns = module_ns->parent)
+ if (module_ns->proc_name->attr.flavor == FL_MODULE)
+ break;
+
+ if (module_ns == NULL)
+ return MATCH_ERROR;
+
for (;;)
{
m = gfc_match_name (name);
@@ -4259,7 +4268,7 @@ gfc_match_modproc (void)
if (m != MATCH_YES)
return MATCH_ERROR;
- if (gfc_get_symbol (name, gfc_current_ns->parent, &sym))
+ if (gfc_get_symbol (name, module_ns, &sym))
return MATCH_ERROR;
if (sym->attr.proc != PROC_MODULE
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 7ab79cbad97..c3fccfa979e 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2007-04-05 Paul Thomas <pault@gcc.gnu.org>
+
+ PR fortran/31292
+ * gfortran.dg/contained_module_proc_1.f90: New test.
+
2007-04-04 Stuart Hastings <stuart@apple.com>
PR 31281
diff --git a/gcc/testsuite/gfortran.dg/contained_module_proc_1.f90 b/gcc/testsuite/gfortran.dg/contained_module_proc_1.f90
new file mode 100644
index 00000000000..a1e58929378
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/contained_module_proc_1.f90
@@ -0,0 +1,40 @@
+! { dg-do run }
+! Tests the check for PR31292, in which the module procedure
+! statement would put the symbol for assign_t in the wrong
+! namespace and this caused the interface checking to fail.
+!
+! Contributed by Tobias Burnus <burnus@gcc.gnu.org>
+!
+module chk_gfortran
+ implicit none
+ type t
+ integer x
+ end type t
+ contains
+ function is_gfortran()
+ logical is_gfortran
+ interface assignment(=)
+ module procedure assign_t
+ end interface assignment(=)
+ type(t) y(3)
+
+ y%x = (/1,2,3/)
+ y = y((/2,3,1/))
+ is_gfortran = y(3)%x == 1
+ end function is_gfortran
+
+ elemental subroutine assign_t(lhs,rhs)
+ type(t), intent(in) :: rhs
+ type(t), intent(out) :: lhs
+
+ lhs%x = rhs%x
+ end subroutine assign_t
+end module chk_gfortran
+
+program fire
+ use chk_gfortran
+ implicit none
+ if(.not. is_gfortran()) call abort()
+end program fire
+! { dg-final { cleanup-modules "chk_gfortran" } }
+