This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[Patch, fortran] PR26393 - ICE on use associated symbols in interfaces.
- From: Paul Thomas <paulthomas2 at wanadoo dot fr>
- To: Tobias Schlüter <tobias dot schlueter at physik dot uni-muenchen dot de>, Steve Kargl <sgk at troutmask dot apl dot washington dot edu>, patch <gcc-patches at gcc dot gnu dot org>, "'fortran at gcc dot gnu dot org'" <fortran at gcc dot gnu dot org>
- Date: Tue, 28 Feb 2006 00:28:40 +0100
- Subject: [Patch, fortran] PR26393 - ICE on use associated symbols in interfaces.
:ADDPATCH fortran:
This patch fixes PR26393, in which an ICE would occur in trans-decl.c
(gfc_get_symbol_decl) because use associated symbols in interface,
specification expressions interfaces are not marked as being referenced.
This is remedied by allowing unreferenced symbols in an interface body.
The testcase is based on that in the PR. I decided that it should
execute both to test that the patch produced working code and to check
that the arrays have the required memory allocated.
Regtested on FC3/Athlon. OK for mainline and, in the fullness of time, 4.1?
Paul
2006-02-28 Paul Thomas <pault@gcc.gnu.org>
PR fortran/26393
* trans-decl.c (gfc_get_symbol_decl): Extend condition that symbols
must be referenced to include unreferenced symbols in an interface
body.
2006-02-28 Paul Thomas <pault@gcc.gnu.org>
PR fortran/26393
gfortran.dg/used_interface_ref.f90
Index: gcc/fortran/trans-decl.c
===================================================================
--- gcc/fortran/trans-decl.c (r+®vision 111471)
+++ gcc/fortran/trans-decl.c (copie de travail)
@@ -846,7 +846,8 @@
tree length = NULL_TREE;
int byref;
- gcc_assert (sym->attr.referenced);
+ gcc_assert (sym->attr.referenced
+ || sym->ns->proc_name->attr.if_source == IFSRC_IFBODY);
if (sym->ns && sym->ns->proc_name->attr.function)
byref = gfc_return_by_reference (sym->ns->proc_name);
! { dg-do run }
! Tests the fix for PR26393, in which an ICE would occur in trans-decl.c
! (gfc_get_symbol_decl) because anzKomponenten is not referenced in the
! interface for solveCConvert. The solution was to assert that the symbol
! is either referenced or in an interface body.
!
! Based on the testcase in the PR.
!
MODULE MODULE_CONC
INTEGER, SAVE :: anzKomponenten = 2
END MODULE MODULE_CONC
MODULE MODULE_THERMOCALC
INTERFACE
FUNCTION solveCConvert ()
USE MODULE_CONC, ONLY: anzKomponenten
REAL :: solveCConvert(1:anzKomponenten)
END FUNCTION solveCConvert
END INTERFACE
END MODULE MODULE_THERMOCALC
SUBROUTINE outDiffKoeff
USE MODULE_CONC
USE MODULE_THERMOCALC
REAL :: buffer_conc(1:anzKomponenten)
buffer_conc = solveCConvert ()
if (any(buffer_conc .ne. (/(real(i), i = 1, anzKomponenten)/))) &
call abort ()
END SUBROUTINE outDiffKoeff
program missing_ref
USE MODULE_CONC
call outDiffKoeff
! Now set anzKomponenten to a value that would cause a segfault if
! buffer_conc and solveCConvert did not have the correct allocation
! of memory.
anzKomponenten = 5000
call outDiffKoeff
end program missing_ref
FUNCTION solveCConvert ()
USE MODULE_CONC, ONLY: anzKomponenten
REAL :: solveCConvert(1:anzKomponenten)
solveCConvert = (/(real(i), i = 1, anzKomponenten)/)
END FUNCTION solveCConvert