Commit 3af57c70 by Bryce McKinlay Committed by Bryce McKinlay

re PR java/20502 (gcj failure if .jar contains same .class twice)

2005-03-17  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.

From-SVN: r96617
parent 5463c726
2005-03-17 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.
2005-03-16 Andrew Haley <aph@redhat.com> 2005-03-16 Andrew Haley <aph@redhat.com>
* expr.c (expand_java_arrayload): Don't generate a * expr.c (expand_java_arrayload): Don't generate a
......
...@@ -823,6 +823,20 @@ load_inner_classes (tree cur_class) ...@@ -823,6 +823,20 @@ load_inner_classes (tree cur_class)
} }
static void 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) parse_class_file (void)
{ {
tree method; tree method;
...@@ -1124,19 +1138,7 @@ java_parse_file (int set_yydebug ATTRIBUTE_UNUSED) ...@@ -1124,19 +1138,7 @@ java_parse_file (int set_yydebug ATTRIBUTE_UNUSED)
/* Exclude file that we see twice on the command line. */ /* Exclude file that we see twice on the command line. */
if (IS_A_COMMAND_LINE_FILENAME_P (node)) if (IS_A_COMMAND_LINE_FILENAME_P (node))
{ duplicate_class_warning (IDENTIFIER_POINTER (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);
}
else else
{ {
tree file_decl = build_decl (TRANSLATION_UNIT_DECL, node, NULL); tree file_decl = build_decl (TRANSLATION_UNIT_DECL, node, NULL);
...@@ -1214,6 +1216,12 @@ java_parse_file (int set_yydebug ATTRIBUTE_UNUSED) ...@@ -1214,6 +1216,12 @@ java_parse_file (int set_yydebug ATTRIBUTE_UNUSED)
jcf_parse (current_jcf); jcf_parse (current_jcf);
DECL_SOURCE_LOCATION (node) = file_start_location; DECL_SOURCE_LOCATION (node) = file_start_location;
TYPE_JCF (current_class) = current_jcf; 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; CLASS_FROM_CURRENTLY_COMPILED_P (current_class) = 1;
TREE_TYPE (node) = current_class; TREE_TYPE (node) = current_class;
} }
...@@ -1236,10 +1244,6 @@ java_parse_file (int set_yydebug ATTRIBUTE_UNUSED) ...@@ -1236,10 +1244,6 @@ java_parse_file (int set_yydebug ATTRIBUTE_UNUSED)
linemap_add (&line_table, LC_LEAVE, false, NULL, 0); linemap_add (&line_table, LC_LEAVE, false, NULL, 0);
#endif #endif
parse_zip_file_entries (); parse_zip_file_entries ();
/*
for (each entry)
CLASS_FROM_CURRENTLY_COMPILED_P (current_class) = 1;
*/
} }
else else
{ {
...@@ -1383,6 +1387,15 @@ parse_zip_file_entries (void) ...@@ -1383,6 +1387,15 @@ parse_zip_file_entries (void)
current_jcf = TYPE_JCF (class); current_jcf = TYPE_JCF (class);
output_class = current_class = 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)) if (TYPE_DUMMY (class))
{ {
/* This is a dummy class, and now we're compiling it /* This is a dummy class, and now we're compiling it
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment