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]

[PATCH] Don't set function's DECL_NAME to an EXPR_WFL


I'm about to check the following patch in.  Alex may not care for
the patch, as it may reduce the ability of gcj to give precise error
messages.  However, setting the DECL_NAME of a FUNCTION_DECL
to a EXPR_WITH_FILE_LOCATION did cause the compiler to crash - I
don't remember exactly where, but it was in the non-java-specific
parts of the gcc.  Clearly the rest of the compiler expects
an IDENTIFIER_NODE, and setting the field to anything else is
at best very fragile.  For example it means debug_tree doesn't
work!

It is no doubt possible to fix the crash by other means.  But
setting the DECL_NAME to a EXPR_WITH_FILE_LOCATION just seems
like the wrong thing to do, so I got rid of it.  I don't know
if any other part of gcc/java depends on there being the
EXPR_WITH_FILE_LOCATION node - but if there are, in my opinion
they should be changed to not do so.  Compiling Kawa and libgcj
did at least indicate that if there are any such places they are
probably well hidden.

The proper way to add more precise location information (i.e.
column numbers) is to add them in addition to DECL_SOURCE_LINE.
I.e. we should add a DECL_SOURCE_COLUMN.  But this is probably
a gcc 3.1 project or later.  (We might consider replacing
file+line by a *range*, so we can display starting and ending
information, like Jikes does.  This would be nice for a GUI.)

2001-01-21  Per Bothner  <per@bothner.com>

	* parse.y (method_header):  Don't set the DECL_NAME of a FUNCTION_DECL
	to a EXPR_WITH_FILE_LOCATION - that is just too fragile and wrong.

Index: parse.y
===================================================================
RCS file: /cvs/gcc/egcs/gcc/java/parse.y,v
retrieving revision 1.244
diff -u -r1.244 parse.y
--- parse.y	2001/01/18 03:07:01	1.244
+++ parse.y	2001/01/21 19:20:08
@@ -4514,16 +4514,6 @@
       DECL_FUNCTION_THROWS (meth) = throws;
     }
 
-  /* We set the DECL_NAME to ID so we can track the location where
-     the function was declared. This allow us to report
-     redefinition error accurately. When method are verified,
-     DECL_NAME is reinstalled properly (using the content of the
-     WFL node ID) (see check_method_redefinition). We don't do that
-     when Object is being defined. Constructor <init> names will be
-     reinstalled the same way. */
-  if (TREE_TYPE (GET_CPC ()) != object_type_node)
-    DECL_NAME (meth) = id;
-
   /* Set the flag if we correctly processed a constructor */
   if (constructor_ok)
     {

-- 
	--Per Bothner
per@bothner.com   http://www.bothner.com/~per/

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