This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [Patch, fortran] PR24325 - ICE in gfc_get_function_type
- From: Paul Thomas <paulthomas2 at wanadoo dot fr>
- To: Fortran List <fortran at gcc dot gnu dot org>, gcc-patches <gcc-patches at gcc dot gnu dot org>
- Date: Fri, 29 Dec 2006 16:56:43 +0100
- Subject: Re: [Patch, fortran] PR24325 - ICE in gfc_get_function_type
- References: <459502B8.4030704@wanadoo.fr> <45951554.50006@wanadoo.fr>
Paul Thomas wrote:
Dear All,
In essence, if we arrive at resolve_function with the function not
already resolved or with the symbol not having FL_UNKNOWN then, for
sure and certain, we are going to produce the ICE in
gfc_get_function_type. Initially, I had the test only detect
FL_VARIABLE to throw the error. However, the opening block in
resolve_symbol treats FL_UNKNOWN and results in them either being
identified as variables or procedures. Thus I think that it is
sufficient to test that the symbol is not a function and that testing
for FL_UNKNOWN adds the belt and braces.
Cancel this for an hour or two. The initial version got regtested
instead of this one - it is fine, so I might just resubmit that one.
However, if I can find the problem with this version I would rather do
that.
It just seems to be the first version that checks if the symbol is a
variable that works. As far as I can tell, all the cases that are going
to cause the ICE are shunted this way, so this should be an all
embracing fix.
OK for trunk and 4.2?
Paul
2006-12-29 Paul Thomas <pault@gcc.gnu.org>
PR fortran/24325
* resolve.c (resolve_function): If the function reference is
FL_UNKNOWN or is not already resolved to be a function, this
is an error.
2006-12-29 Paul Thomas <pault@gcc.gnu.org>
PR fortran/24325
* gfortran.dg/func_decl_3.f90: New test.
Index: gcc/fortran/resolve.c
===================================================================
*** gcc/fortran/resolve.c (revision 120244)
--- gcc/fortran/resolve.c (working copy)
*************** resolve_function (gfc_expr * expr)
*** 1456,1461 ****
--- 1456,1468 ----
if (expr->symtree)
sym = expr->symtree->n.sym;
+ if (sym && sym->attr.flavor == FL_VARIABLE)
+ {
+ gfc_error ("'%s' at %L is not a function",
+ sym->name, &expr->where);
+ return FAILURE;
+ }
+
/* If the procedure is not internal, a statement function or a module
procedure,it must be external and should be checked for usage. */
if (sym && !sym->attr.dummy && !sym->attr.contained
Index: gcc/testsuite/gfortran.dg/func_decl_3.f90
===================================================================
*** gcc/testsuite/gfortran.dg/func_decl_3.f90 (revision 0)
--- gcc/testsuite/gfortran.dg/func_decl_3.f90 (revision 0)
***************
*** 0 ****
--- 1,15 ----
+ ! { dg-do compile }
+ ! Tests the fix for PR24325 in which the lack of any declaration
+ ! that foo is a function or even a procedure was not detected.
+ !
+ ! Contributed by Jakub Jelinek <jakub@gcc.gnu.org>
+ !
+ integer foo
+ call test
+ contains
+ subroutine test
+ integer :: i
+ i = foo () ! { dg-error "is not a function" }
+ end subroutine test
+ end
+