Hello,
Does anyone have any tips for how to trace an internal compiler error?
I am making a patch that involves changing function parameters and
clearly I've made some mistake in building the GIMPLE tree, but I'm
having a hard time figuring out where it is.
Currently SVN has something like this:
stat = gfc_create_var (gfc_int4_type_node, "stat");
pstat = gfc_build_addr_expr (NULL_TREE, stat);
...
gfc_allocate_allocatable (... pstat);
It turns out that the pointer is not needed, so I am changing the above
to this:
stat = gfc_create_var (gfc_int4_type_node, "stat");
...
gfc_allocate_allocatable (... stat);
I thought I had made all the correct changes inside the allocate
function. For example:
1) The line:
tree status_type = status ? TREE_TYPE( TREE_TYPE (status)) : NULL_TREE;
Becomes:
tree status_type = status ? TREE_TYPE (status) : NULL_TREE;
2) The line:
on_error = fold_build2_loc (input_location, MODIFY_EXPR, status_type,
fold_build1_loc (input_location, INDIRECT_REF,
status_type, status),
build_int_cst (status_type, LIBERROR_ALLOCATION));
Becomes:
on_error = fold_build2_loc (input_location, MODIFY_EXPR, status_type,
status,
build_int_cst (status_type, LIBERROR_ALLOCATION));
And I think those are mainly the changes. Btw, for completeness my
current non-functioning patch is attached and a very simple program that
gives a segfault is below:
program main
implicit none
real,allocatable :: mol
integer :: i
! allocate (mol) ! This works.
allocate (mol, stat=i) ! This fails.
end program main
Cheers,
Daniel.