This is the mail archive of the gcc-patches@gcc.gnu.org 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]

[Patch, fortran] PR24325 - ICE in gfc_get_function_type


:ADDPATCH fortran:

I fell on this one quite accidentally - I still cannot quite believe that the fix is so simple :-)

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.

Regtested on Cygwin_NT/amd64 - OK for trunk and, in a week or so, 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,1469 ----
    if (expr->symtree)
      sym = expr->symtree->n.sym;
  
+   if (sym && !(sym->attr.flavor == FL_PROCEDURE && sym->attr.function)
+ 	  && sym->attr.flavor != FL_UNKNOWN)
+     {
+       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
+ 

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