[gfortran] Work around frontend bugs.

Paul Brook paul@nowt.org
Mon Oct 13 23:26:00 GMT 2003


For various reasons the gfortran parser sometimes creates symbols for 
variables which don't exist. This is fairly harmless, except that things 
fall over later on when we try and create tree nodes for these incomplete 
symbols.

The proper fix would be to avoid createing/adding these symbols. Until such 
a fix appears I've worked around it by ignoring any obviously broken 
symbols.

Applied to tree-ssa branch.

Paul

2003-10-13  Paul Brook  <paul@nowt.org>

	* trans-decl.c (generate_local_decl): Don't create junk variables.

--- clean/tree-ssa/gcc/fortran/trans-decl.c
+++ gcc/gcc/fortran/trans-decl.c
@@ -1768,6 +1768,17 @@ generate_local_decl (gfc_symbol * sym)
 {
   if (sym->attr.flavor == FL_VARIABLE)
     {
+      /* TODO: The frontend sometimes creates symbols for things which 
don't
+         actually exist.  E.g. common block names and the names of formal
+	 arguments.  The latter are created while attempting to parse
+	 the argument list as a substring reference.
+
+	 The proper fix is to avoid adding these symbols in the first place.
+	 For now we hack round it by ignoring anything with an unknown type.
+       */
+      if (sym->ts.type == BT_UNKNOWN)
+	return;
+
       if (sym->attr.referenced)
         gfc_get_symbol_decl (sym);
       else if (sym->attr.dummy)
-------------- next part --------------
! This caused problems because we created a symbol for P while
! trying to parse the argument list as a substring reference.
program named_args
  implicit none
  integer, parameter :: realdp = selected_real_kind(p=8,r=30)
end program


More information about the Fortran mailing list