[patch,gfortran] PR 18568: Component not found
Erik Edelmann
erik.edelmann@iki.fi
Tue Oct 4 17:53:00 GMT 2005
:ADDPATCH fortran:
Re-continuing my crusade against trivial bugs, here's a patch for
PR 18568. For code like this
module ints
type :: bar
integer, pointer :: th(:)
end type bar
contains
function foo(b)
type(bar), intent(in) :: b
integer :: foo(size(b%th))
end function foo
end module ints
program size_test
use ints
end program size_test
we get the errormessage:
Internal Error at (1):
find_array_spec(): Component not found
The reason for this is that in the function
resolve.c/find_array_spec(), when searching for the component
'th' of 'b', we search through the list of components pointed to
by e->symtree->n.sym->components (where e->symtree->n.sym is the
dummy variable 'b' in 'foo' for this case). This is wrong,
because the components of 'b' are not pointed to by
e->symtree->n.sym->components; they are pointed to by
e->symtree->n.sym->ts.derived->components.
Bubblestrapped and reg.-tested on mainline, Linux/x86. Please
commit if OK.
Erik
2005-10-04 Erik Edelmann <erik.edelmann@iki.fi>
PR 18568
* resolve.c (find_array_spec): Search through the list of
components in the symbol of the type instead of the symbol of the
variable.
2005-10-04 Erik Edelmann <erik.edelmann@iki.fi>
PR 18568
gfrotran.dg/der_pointer_3.f90: New test.
-------------- next part --------------
Index: gcc/fortran/resolve.c
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/fortran/resolve.c,v
retrieving revision 1.57
diff -u -p -r1.57 resolve.c
--- gcc/fortran/resolve.c 1 Oct 2005 07:39:05 -0000 1.57
+++ gcc/fortran/resolve.c 4 Oct 2005 17:17:08 -0000
@@ -1912,7 +1912,7 @@ find_array_spec (gfc_expr * e)
gfc_ref *ref;
as = e->symtree->n.sym->as;
- c = e->symtree->n.sym->components;
+ c = e->symtree->n.sym->ts.derived ? e->symtree->n.sym->ts.derived->components : NULL;
for (ref = e->ref; ref; ref = ref->next)
switch (ref->type)
@@ -1940,7 +1940,6 @@ find_array_spec (gfc_expr * e)
as = c->as;
}
- c = c->ts.derived->components;
break;
case REF_SUBSTRING:
-------------- next part --------------
! { dg-do compile }
! PR 18568
! Find pointer-to-array components
module ints
type :: bar
integer, pointer :: th(:)
end type bar
contains
function foo(b)
type(bar), intent(in) :: b
integer :: foo(size(b%th))
foo = 0
end function foo
end module ints
program size_test
use ints
end program size_test
More information about the Fortran
mailing list