This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [Patch, fortran] PR24325 - ICE in gfc_get_function_type

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?


2006-12-29  Paul Thomas  <>

	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  <>

	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 <>
+ !
+   integer foo
+   call test
+ contains
+   subroutine test
+     integer :: i
+     i = foo () ! { dg-error "is not a function" }
+   end subroutine test
+ end

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]