Commit 8de10a62 by Paul Thomas

re PR fortran/32464 (ICE: USE in contained subroutine)

2007-06-25  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/32464
	* resolve.c (check_host_association): Return if the old symbol
	is use associated.  Introduce retval to reduce the number of
	evaluations of the first-order return value.

	PR fortran/31494
	* match.c (gfc_match_call): If a host associated symbol is not
	a subroutine, build a new symtree/symbol in the current name
	space.


2007-06-25  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/32464
	* gfortran.dg/host_assoc_function_2.f90: New test.

	PR fortran/31494
	* gfortran.dg/host_assoc_call_1.f90: New test.

From-SVN: r126000
parent c861db66
2007-06-25 Paul Thomas <pault@gcc.gnu.org>
PR fortran/32464
* resolve.c (check_host_association): Return if the old symbol
is use associated. Introduce retval to reduce the number of
evaluations of the first-order return value.
PR fortran/31494
* match.c (gfc_match_call): If a host associated symbol is not
a subroutine, build a new symtree/symbol in the current name
space.
2007-06-24 Tobias Burnus <burnus@net-de> 2007-06-24 Tobias Burnus <burnus@net-de>
PR fortran/32460 PR fortran/32460
......
...@@ -2170,13 +2170,20 @@ gfc_match_call (void) ...@@ -2170,13 +2170,20 @@ gfc_match_call (void)
return MATCH_ERROR; return MATCH_ERROR;
sym = st->n.sym; sym = st->n.sym;
gfc_set_sym_referenced (sym);
if (!sym->attr.generic if (sym->ns != gfc_current_ns
&& !sym->attr.subroutine && !sym->attr.generic
&& gfc_add_subroutine (&sym->attr, sym->name, NULL) == FAILURE) && !sym->attr.subroutine
&& gfc_get_sym_tree (name, NULL, &st) == 1)
return MATCH_ERROR; return MATCH_ERROR;
sym = st->n.sym;
if (gfc_add_subroutine (&sym->attr, sym->name, NULL) == FAILURE)
return MATCH_ERROR;
gfc_set_sym_referenced (sym);
if (gfc_match_eos () != MATCH_YES) if (gfc_match_eos () != MATCH_YES)
{ {
m = gfc_match_actual_arglist (1, &arglist); m = gfc_match_actual_arglist (1, &arglist);
......
...@@ -3224,11 +3224,16 @@ check_host_association (gfc_expr *e) ...@@ -3224,11 +3224,16 @@ check_host_association (gfc_expr *e)
locus temp_locus; locus temp_locus;
gfc_expr *expr; gfc_expr *expr;
int n; int n;
bool retval = e->expr_type == EXPR_FUNCTION;
if (e->symtree == NULL || e->symtree->n.sym == NULL) if (e->symtree == NULL || e->symtree->n.sym == NULL)
return e->expr_type == EXPR_FUNCTION; return retval;
old_sym = e->symtree->n.sym; old_sym = e->symtree->n.sym;
if (old_sym->attr.use_assoc)
return retval;
if (gfc_current_ns->parent if (gfc_current_ns->parent
&& gfc_current_ns->parent->parent && gfc_current_ns->parent->parent
&& old_sym->ns != gfc_current_ns) && old_sym->ns != gfc_current_ns)
...@@ -3244,7 +3249,7 @@ check_host_association (gfc_expr *e) ...@@ -3244,7 +3249,7 @@ check_host_association (gfc_expr *e)
gfc_free_ref_list (e->ref); gfc_free_ref_list (e->ref);
e->ref = NULL; e->ref = NULL;
if (e->expr_type == EXPR_FUNCTION) if (retval)
{ {
gfc_free_actual_arglist (e->value.function.actual); gfc_free_actual_arglist (e->value.function.actual);
e->value.function.actual = NULL; e->value.function.actual = NULL;
...@@ -3271,7 +3276,7 @@ check_host_association (gfc_expr *e) ...@@ -3271,7 +3276,7 @@ check_host_association (gfc_expr *e)
gfc_current_locus = temp_locus; gfc_current_locus = temp_locus;
} }
} }
/* This might have changed! */
return e->expr_type == EXPR_FUNCTION; return e->expr_type == EXPR_FUNCTION;
} }
......
2007-06-25 Paul Thomas <pault@gcc.gnu.org>
PR fortran/32464
* gfortran.dg/host_assoc_function_2.f90: New test.
PR fortran/31494
* gfortran.dg/host_assoc_call_1.f90: New test.
2007-06-24 Jerry DeLisle <jvdelisle@gcc.gnu.org> 2007-06-24 Jerry DeLisle <jvdelisle@gcc.gnu.org>
* gfortran.dg/secnds-1.f: Revise test to reduce random errors. * gfortran.dg/secnds-1.f: Revise test to reduce random errors.
! { dg-do compile }
! Tests the fix for PR31494, where the call of sub2 would reference
! the variable, rather than the contained subroutine.
!
! Contributed by Michael Richmond <michael.a.richmond@nasa.gov>
!
MODULE ksbin2_aux_mod
REAL, DIMENSION(1) :: sub2
CONTAINS
SUBROUTINE sub1
CALL sub2
CONTAINS
SUBROUTINE sub2
END SUBROUTINE sub2
END SUBROUTINE sub1
END MODULE ksbin2_aux_mod
! { dg-final { cleanup-modules "ksbin2_aux_mod" } }
! { dg-do compile }
! Tests the fix for PR32464, where the use associated procedure would
! mess up the check for "grandparent" host association.
!
! Contributed by Harald Anlauf <anlauf@gmx.de>
!
module gfcbug64_mod1
implicit none
public :: inverse
interface inverse
module procedure copy
end interface
contains
function copy (d) result (y)
real, intent(in) :: d(:)
real :: y(size (d)) ! <- this version kills gfortran
! real, intent(in) :: d
! real :: y
y = d
end function copy
end module gfcbug64_mod1
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
module gfcbug64_mod2
implicit none
contains
subroutine foo (x_o)
real, intent(in) :: x_o(:)
integer :: s(size (x_o)) ! <- this line kills gfortran
contains
subroutine bar ()
use gfcbug64_mod1, only: inverse ! <- this line kills gfortran
end subroutine bar
end subroutine foo
end module gfcbug64_mod2
! { dg-final { cleanup-modules "gfcbug64_mod1 gfcbug64_mod2" } }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment