This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
Re: Patch: PR java/20502
- From: Bryce McKinlay <mckinlay at redhat dot com>
- To: Bryce McKinlay <mckinlay at redhat dot com>
- Cc: java-patches at gcc dot gnu dot org, gcc-patches at gcc dot gnu dot org
- Date: Wed, 16 Mar 2005 23:00:53 -0500
- Subject: Re: Patch: PR java/20502
- References: <4238DF8A.4070704@redhat.com>
Bryce McKinlay wrote:
GCJ would crash when compiling a .jar file which contains duplicate
copies of the same class. This patch changes it to issue a warning,
ignore the duplicate class, and not crash.
OK to commit?
That patch had a bug - here's a fixed (and simpler) version. No regressions.
OK to commit?
Bryce
2005-03-16 Bryce McKinlay <mckinlay@redhat.com>
PR java/20502
* jcf-parse.c (duplicate_class_warning): New function.
(java_parse_file): Call duplicate_class_warning if
CLASS_FROM_CURRENTLY_COMPILED_P is already set.
(parse_zip_file_entries): Likewise. Also set
CLASS_FROM_CURRENTLY_COMPILED_P.
Index: jcf-parse.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/jcf-parse.c,v
retrieving revision 1.183
diff -u -r1.183 jcf-parse.c
--- jcf-parse.c 12 Feb 2005 15:21:14 -0000 1.183
+++ jcf-parse.c 17 Mar 2005 03:55:52 -0000
@@ -823,6 +823,20 @@
}
static void
+duplicate_class_warning (const char *filename)
+{
+ location_t warn_loc;
+#ifdef USE_MAPPED_LOCATION
+ linemap_add (&line_table, LC_RENAME, 0, filename, 0);
+ warn_loc = linemap_line_start (&line_table, 0, 1);
+#else
+ warn_loc.file = filename;
+ warn_loc.line = 0;
+#endif
+ warning ("%Hduplicate class will only be compiled once", &warn_loc);
+}
+
+static void
parse_class_file (void)
{
tree method;
@@ -1124,19 +1138,7 @@
/* Exclude file that we see twice on the command line. */
if (IS_A_COMMAND_LINE_FILENAME_P (node))
- {
- location_t warn_loc;
-#ifdef USE_MAPPED_LOCATION
- linemap_add (&line_table, LC_RENAME, 0,
- IDENTIFIER_POINTER (node), 0);
- warn_loc = linemap_line_start (&line_table, 0, 1);
-#else
- warn_loc.file = IDENTIFIER_POINTER (node);
- warn_loc.line = 0;
-#endif
- warning ("%Hsource file seen twice on command line and "
- "will be compiled only once", &warn_loc);
- }
+ duplicate_class_warning (IDENTIFIER_POINTER (node));
else
{
tree file_decl = build_decl (TRANSLATION_UNIT_DECL, node, NULL);
@@ -1214,6 +1216,12 @@
jcf_parse (current_jcf);
DECL_SOURCE_LOCATION (node) = file_start_location;
TYPE_JCF (current_class) = current_jcf;
+ if (CLASS_FROM_CURRENTLY_COMPILED_P (current_class))
+ {
+ /* We've already compiled this class. */
+ duplicate_class_warning (filename);
+ continue;
+ }
CLASS_FROM_CURRENTLY_COMPILED_P (current_class) = 1;
TREE_TYPE (node) = current_class;
}
@@ -1236,10 +1244,6 @@
linemap_add (&line_table, LC_LEAVE, false, NULL, 0);
#endif
parse_zip_file_entries ();
- /*
- for (each entry)
- CLASS_FROM_CURRENTLY_COMPILED_P (current_class) = 1;
- */
}
else
{
@@ -1383,6 +1387,15 @@
current_jcf = TYPE_JCF (class);
output_class = current_class = class;
+ if (CLASS_FROM_CURRENTLY_COMPILED_P (current_class))
+ {
+ /* We've already compiled this class. */
+ duplicate_class_warning (current_jcf->filename);
+ break;
+ }
+
+ CLASS_FROM_CURRENTLY_COMPILED_P (current_class) = 1;
+
if (TYPE_DUMMY (class))
{
/* This is a dummy class, and now we're compiling it