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]
Other format: [Raw text]

Patch: PR java/20031 - ICE on missing files


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,

  This patch fixes both the problems reported in PR java/20031,
which was a 4.0/4.1 regression.

It is a follow-up to the discussion in:

  http://gcc.gnu.org/ml/java/2005-09/msg00051.html

Tested on i686-pc-linux-gnu, Jacks included, and introduces
no new failures.

The contentious bit would probably be my proposal to use
TYPE_DUMMY on a RECORD_TYPE node to indicate a failed
loading of the class, even in the non-indirect-dispatch
case when VERBOSE is true and to use this to not bother
to lay out a class's methods if it failed loading.

As I understand it, VERBOSE is set to 1 for load_class()
when we expect the class to be found and consider it an
error if it is not. In this case, if the class failed
loading, there does not seem to be any hope of finding it
later and therefore it is better to "poison" the RECORD_TYPE
denoting the class. I would like to know if this assumption
is invalid.

I noticed that the "if (!class_loaded)" loop did anything
useful only when VERBOSE is set, so I simplified the conditional
statements a bit. The diff output might be a bit unreadable,
so here is the new structure:
- --------------------------- 8< ---------------------------
  if (!class_loaded && verbose)
    {
      if (flag_verify_invocations || ! flag_indirect_dispatch
          || flag_emit_class_files)
        {
          error ("cannot find file for class %s", IDENTIFIER_POINTER (saved));
        }
      else if (!quiet_flag)
        /* This is just a diagnostic during testing, not a real problem.  */
        warning (0, "cannot find file for class %s",
                 IDENTIFIER_POINTER (saved));

      /* Fake it.  */
      if (TREE_CODE (class_or_name) == RECORD_TYPE)
        {
          set_super_info (0, class_or_name, object_type_node, 0);
          TYPE_DUMMY (class_or_name) = 1;
          /* We won't be able to output any debug info for this class.  */
          DECL_IGNORED_P (TYPE_NAME (class_or_name)) = 1;
        }
    }
- --------------------------- 8< ---------------------------

OK for mainline?

Thanks,
Ranjit.

:ADDPATCH java:

- --
Ranjit Mathew      Email: rmathew AT gmail DOT com

Bangalore, INDIA.    Web: http://ranjitmathew.hostingzero.com/


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (MingW32)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFDIV8kYb1hx2wRS48RArP/AKCeYe2qlqqaP+mEj3tUuXXDm4KJqgCgjpK2
obL6GnJDKwHzM4PqhspsqTI=
=2g9q
-----END PGP SIGNATURE-----
Index: ChangeLog
from  Ranjit Mathew  <rmathew@hotmail.com>

	PR java/20031
	* parse.y (java_parser_context_restore_global): Set
	EXPR_WFL_FILENAME_NODE of WFL_OPERATOR only if INPUT_FILENAME is
	not NULL.
	(java_layout_seen_class_methods): Lay out a class's methods only
	if it was actually loaded.
	* jcf-parse.c (load_class): Simplify conditional statement for
	the case when the class is not loaded.  Use TYPE_DUMMY for a 
	RECORD_TYPE node to indicate a class which could not be loaded.

Index: parse.y
===================================================================
--- parse.y	2005-09-09 12:13:10.000000000 +0530
+++ parse.y	2005-09-09 12:17:23.000000000 +0530
@@ -2815,5 +2815,6 @@ java_parser_context_restore_global (void
     SET_EXPR_LOCATION (wfl_operator, ctxp->save_location);
 #else
-    EXPR_WFL_FILENAME_NODE (wfl_operator) = get_identifier (input_filename);
+    if (input_filename)
+      EXPR_WFL_FILENAME_NODE (wfl_operator) = get_identifier (input_filename);
 #endif
   current_function_decl = ctxp->function_decl;
@@ -7719,5 +7720,6 @@ java_layout_seen_class_methods (void)
             load_class (cls, 0);
 
-          layout_class_methods (cls);
+          if (!TYPE_DUMMY (cls))
+	    layout_class_methods (cls);
         }
 
Index: jcf-parse.c
===================================================================
--- jcf-parse.c	2005-09-09 12:13:20.000000000 +0530
+++ jcf-parse.c	2005-09-09 12:33:14.000000000 +0530
@@ -619,5 +619,7 @@ read_class (tree name)
 /* Load CLASS_OR_NAME. CLASS_OR_NAME can be a mere identifier if
    called from the parser, otherwise it's a RECORD_TYPE node. If
-   VERBOSE is 1, print error message on failure to load a class. */
+   VERBOSE is 1, print error message on failure to load a class.
+   If CLASS_OR_NAME is a RECORD_TYPE node and the class was not
+   loaded, mark it TYPE_DUMMY if VERBOSE is 1.  */
 void
 load_class (tree class_or_name, int verbose)
@@ -706,28 +708,24 @@ load_class (tree class_or_name, int verb
     }
   
-  if (!class_loaded)
+  if (!class_loaded && verbose)
     {
       if (flag_verify_invocations || ! flag_indirect_dispatch
 	  || flag_emit_class_files)
 	{
-	  if (verbose)
-	    error ("cannot find file for class %s", IDENTIFIER_POINTER (saved));
-	}
-      else if (verbose)
-	{
-	  /* This is just a diagnostic during testing, not a real problem.  */
-	  if (!quiet_flag)
-	    warning (0, "cannot find file for class %s", 
-		     IDENTIFIER_POINTER (saved));
-	  
-	  /* Fake it.  */
-	  if (TREE_CODE (class_or_name) == RECORD_TYPE)
-	    {
-	      set_super_info (0, class_or_name, object_type_node, 0);
-	      TYPE_DUMMY (class_or_name) = 1;
-	      /* We won't be able to output any debug info for this class.  */
-	      DECL_IGNORED_P (TYPE_NAME (class_or_name)) = 1;
-	    }
+          error ("cannot find file for class %s", IDENTIFIER_POINTER (saved));
 	}
+      else if (!quiet_flag)
+        /* This is just a diagnostic during testing, not a real problem.  */
+        warning (0, "cannot find file for class %s",
+                 IDENTIFIER_POINTER (saved));
+
+      /* Fake it.  */
+      if (TREE_CODE (class_or_name) == RECORD_TYPE)
+        {
+          set_super_info (0, class_or_name, object_type_node, 0);
+          TYPE_DUMMY (class_or_name) = 1;
+          /* We won't be able to output any debug info for this class.  */
+          DECL_IGNORED_P (TYPE_NAME (class_or_name)) = 1;
+        }
     }
 }

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