jcf-io.c (open_class): Set filename field.
authorPer Bothner <per@bothner.com>
Thu, 30 Aug 2001 21:28:20 +0000 (14:28 -0700)
committerPer Bothner <bothner@gcc.gnu.org>
Thu, 30 Aug 2001 21:28:20 +0000 (14:28 -0700)
* jcf-io.c (open_class):  Set filename field.

* jcf-parse,c (parse_class_file):  Set current_function_decl
for better error message when Code attribute is missing.

* lang.c (put_decl_node, lang_print_error):  Re-arrange for
better diagnostics, especially for constructors.

From-SVN: r45299

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

index a7e57184ca8e5323d5105bfe16fe4a6684a33fb5..02297cfd6150a39ebf35f1fe7c21fb58d49f8620 100644 (file)
@@ -1,3 +1,13 @@
+2001-08-30  Per Bothner  <per@bothner.com>
+
+       * jcf-io.c (open_class):  Set filename field.
+
+       * jcf-parse,c (parse_class_file):  Set current_function_decl
+       for better error message when Code attribute is missing.
+
+       * lang.c (put_decl_node, lang_print_error):  Re-arrange for
+       better diagnostics, especially for constructors.
+       
 2001-08-30  Per Bothner  <per@bothner.com>
 
        * jcf-write.c (generate_classfile):  Don't write ConstantValue
index f8a0f591db97861bf2ff535537bc02301ffb2fe6..a2809767444ae9486475addea5858de25248a749 100644 (file)
@@ -242,6 +242,7 @@ DEFUN(open_class, (filename, jcf, stream, dep_name),
       jcf->read_ptr = NULL;
       jcf->read_end = NULL;
       jcf->read_state = stream;
+      jcf->filename = filename;
       jcf->filbuf = jcf_filbuf_from_stdio;
     }
   else
@@ -556,7 +557,9 @@ DEFUN(jcf_print_utf8_replace, (stream, str, length, in_char, out_char),
 
 /* Check that all the cross-references in the constant pool are
    valid.  Returns 0 on success.
-   Otherwise, returns the index of the (first) invalid entry. */
+   Otherwise, returns the index of the (first) invalid entry.
+   Only checks internal consistency, but does not check that
+   any classes, fields, or methods are valid.*/
 
 int
 DEFUN(verify_constant_pool, (jcf),
index b52f1c11fb1533710d1bdc74e350f4f10ed8ab4c..1247ece6caf3a8e3aed339514dd99b02fb29a41f 100644 (file)
@@ -840,6 +840,7 @@ parse_class_file ()
 
       if (DECL_CODE_OFFSET (method) == 0)
        {
+         current_function_decl = method;
          error ("missing Code attribute");
          continue;
        }
index dd997a50336a0a6e23ba002325980d2123577857..951d2996b30557790e6dcb4129e1f3b390073429 100644 (file)
@@ -522,32 +522,36 @@ put_decl_node (node)
   if (TREE_CODE_CLASS (TREE_CODE (node)) == 'd'
       && DECL_NAME (node) != NULL_TREE)
     {
-      /* We want to print the type the DECL belongs to. We don't do
-        that when we handle constructors. */
-      if (TREE_CODE (node) == FUNCTION_DECL
-         && ! DECL_CONSTRUCTOR_P (node)
-         && ! DECL_ARTIFICIAL (node) && DECL_CONTEXT (node))
+      if (TREE_CODE (node) == FUNCTION_DECL)
        {
-         put_decl_node (TYPE_NAME (DECL_CONTEXT (node)));
-         put_decl_string (".", 1);
-       }
-      if (! DECL_CONSTRUCTOR_P (node))
-       put_decl_node (DECL_NAME (node));
-      if (TREE_CODE (node) == FUNCTION_DECL && TREE_TYPE (node) != NULL_TREE)
-       {
-         int i = 0;
-         tree args = TYPE_ARG_TYPES (TREE_TYPE (node));
-         if (TREE_CODE (TREE_TYPE (node)) == METHOD_TYPE)
-           args = TREE_CHAIN (args);
-         put_decl_string ("(", 1);
-         for ( ; args != end_params_node;  args = TREE_CHAIN (args), i++)
+         /* We want to print the type the DECL belongs to. We don't do
+            that when we handle constructors. */
+         if (! DECL_CONSTRUCTOR_P (node)
+             && ! DECL_ARTIFICIAL (node) && DECL_CONTEXT (node))
            {
-             if (i > 0)
-               put_decl_string (",", 1);
-             put_decl_node (TREE_VALUE (args));
+             put_decl_node (TYPE_NAME (DECL_CONTEXT (node)));
+             put_decl_string (".", 1);
+           }
+         if (! DECL_CONSTRUCTOR_P (node))
+           put_decl_node (DECL_NAME (node));
+         if (TREE_TYPE (node) != NULL_TREE)
+           {
+             int i = 0;
+             tree args = TYPE_ARG_TYPES (TREE_TYPE (node));
+             if (TREE_CODE (TREE_TYPE (node)) == METHOD_TYPE)
+               args = TREE_CHAIN (args);
+             put_decl_string ("(", 1);
+             for ( ; args != end_params_node;  args = TREE_CHAIN (args), i++)
+               {
+                 if (i > 0)
+                   put_decl_string (",", 1);
+                 put_decl_node (TREE_VALUE (args));
+               }
+             put_decl_string (")", 1);
            }
-         put_decl_string (")", 1);
        }
+      else
+       put_decl_node (DECL_NAME (node));
     }
   else if (TREE_CODE_CLASS (TREE_CODE (node)) == 't'
       && TYPE_NAME (node) != NULL_TREE)
@@ -648,7 +652,10 @@ lang_print_error (context, file)
       else
        {
          const char *name = lang_printable_name (current_function_decl, 2);
-         fprintf (stderr, "In method `%s':\n", name);
+         fprintf (stderr, "In %s `%s':\n",
+                  (DECL_CONSTRUCTOR_P (current_function_decl) ? "constructor" 
+                   : "method"),
+                  name);
        }
 
       last_error_function = current_function_decl;