]> gcc.gnu.org Git - gcc.git/commitdiff
re PR java/20502 (gcj failure if .jar contains same .class twice)
authorBryce McKinlay <mckinlay@redhat.com>
Thu, 17 Mar 2005 15:54:20 +0000 (15:54 +0000)
committerBryce McKinlay <bryce@gcc.gnu.org>
Thu, 17 Mar 2005 15:54:20 +0000 (15:54 +0000)
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

gcc/java/ChangeLog
gcc/java/jcf-parse.c

index 38edfef09cb8af159dfa1ef813cac3c6afbc6f45..cd374a2d8e9eae1aefee7faf8244c4b98d3201e8 100644 (file)
@@ -1,3 +1,12 @@
+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>
 
        * expr.c (expand_java_arrayload): Don't generate a
index 3a4c780e77a30adb83a5ca225fa6e0930142262e..2af480d806aac8652cb060d240ffb989df89abf1 100644 (file)
@@ -822,6 +822,20 @@ load_inner_classes (tree cur_class)
     }
 }
 
+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)
 {
@@ -1124,19 +1138,7 @@ java_parse_file (int set_yydebug ATTRIBUTE_UNUSED)
          /* 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 @@ java_parse_file (int set_yydebug ATTRIBUTE_UNUSED)
          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 @@ java_parse_file (int set_yydebug ATTRIBUTE_UNUSED)
          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 @@ parse_zip_file_entries (void)
            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
This page took 0.081199 seconds and 5 git commands to generate.