This is the mail archive of the gcc-bugs@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]

[Bug fortran/23308] named common block confused as procedure - runtime segfault



------- Comment #3 from pault at gcc dot gnu dot org  2006-01-07 17:07 -------
(In reply to comment #2)
> Note I think fixing PR 25710 and the mentioned problem of not keeping symbols
> correctly will fix this bug.  I have been trying to fix this but it is hard.

I notice that there is a handle in gfortran.h to deal with this:

/* Global symbols are symbols of global scope. Currently we only use
   this to detect collisions already when parsing.
   TODO: Extend to verify procedure calls.  */

typedef struct gfc_gsymbol
{
  BBT_HEADER(gfc_gsymbol);

  const char *name;
  enum { GSYM_UNKNOWN=1, GSYM_PROGRAM, GSYM_FUNCTION, GSYM_SUBROUTINE,
        GSYM_MODULE, GSYM_COMMON, GSYM_BLOCK_DATA } type;

  int defined, used;
  locus where;
}
gfc_gsymbol;

extern gfc_gsymbol *gfc_gsym_root;

and in symbol.c

/* Search a tree for the global symbol.  */

gfc_gsymbol *
gfc_find_gsymbol (gfc_gsymbol *symbol, const char *name)
{

++++friends

Astonishingly, none of this is ever used!

The experimental patch below picks up pr25710 but not this one.  COMMON blocks
need to be given a gsymbol, methinks.

Paul

Index: gcc/fortran/resolve.c
===================================================================
*** gcc/fortran/resolve.c       (revision 109449)
--- gcc/fortran/resolve.c       (working copy)
*************** resolve_function (gfc_expr * expr)
*** 1157,1162 ****
--- 1157,1172 ----
    try t;
    int temp;

+   gfc_gsymbol * gsym;
+ 
+   gsym = gfc_find_gsymbol (gfc_gsym_root, expr->symtree->n.sym->name);
+ 
+   if ((gsym && gsym->type != GSYM_UNKNOWN && gsym->type != GSYM_FUNCTION)
+        ||
+       (expr->symtree && !expr->symtree->n.sym->attr.external &&
!expr->symtree->n.sym->attr.subroutine))
+     gfc_warning_now ("CALL at %L to procedure %s which is not a function",
+                    &expr->where, expr->symtree->n.sym->name);
+ 
    /* Switch off assumed size checking and do this again for certain kinds
       of procedure, once the procedure itself is resolved.  */
    need_full_assumed_size++;
*************** resolve_call (gfc_code * c)
*** 1510,1515 ****
--- 1520,1535 ----
  {
    try t;

+   gfc_gsymbol * gsym;
+ 
+   gsym = gfc_find_gsymbol (gfc_gsym_root, c->symtree->n.sym->name);
+ 
+   if ((gsym && gsym->type != GSYM_UNKNOWN && gsym->type != GSYM_SUBROUTINE)
+        ||
+       (c->symtree && !c->symtree->n.sym->attr.external &&
!c->symtree->n.sym->attr.subroutine))
+     gfc_warning_now ("CALL at %L to procedure %s which is not a subroutine",
+                    &c->loc, c->symtree->n.sym->name);
+ 
    /* Switch off assumed size checking and do this again for certain kinds
       of procedure, once the procedure itself is resolved.  */
    need_full_assumed_size++;


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23308



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