This is the mail archive of the java-patches@sourceware.cygnus.com mailing list for the Java project.


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

Patch: bug fix in parse.y(resolve_field_access)


When compiled with --enable-checking, gcj dumps core at
parse.y(remove_field_access) since it may attempt to
fetch a declaration name with DECL_NAME for something
that is an expression (tree type 'e') and not a declaration
(tree type 'd').  This might also be a bug in 
resolve_qualified_expression_name, but I couldn't figure
out where there.  Anyhow, this patch fixes the crash
and does not seem to have any ill effects.

To test, attemt to compile the following code when gcj
is compiled with --enable-checking. 

public class Test {
  public Bar bar() {
    return null;
  }

  public void foo(Zap obj) {
    if (!(bar().zap(obj.getZap()))) {
      return;
    }
  }
}

class Bar {
  public boolean zap(Class z) {
    return null;
  }
}

class Zap {
  public Class getZap() {
    return null;
  }
}

The compiler barfs at line 8.

$ /usr/local/rcx/bin/gcj -fclasspath=/home/pnr/rcx/java -c Test.java    
Test.java: In class `Test':
Test.java: In method `foo(Zap)':
Test.java:8: Tree check: expected class 'd', have 'e' (call_expr)
Test.java:8: Internal compiler error in `resolve_field_access', at
./parse.y:6616
Please submit a full bug report.

2000-02-10  Pekka Nikander  <pnr@teldanex.tcm.hut.fi>

	* parse.y (resolve_field_access): Add DECL_P(decl) 
	  before checking DECL_NAME(decl) for length_indentifier_node.

Index: parse.y
===================================================================
RCS file: /cvs/gcc/egcs/gcc/java/parse.y,v
retrieving revision 1.134
diff -c -3 -p -r1.134 parse.y
*************** resolve_field_access (qual_wfl, field_de
*** 6572,6578 ****
      return error_mark_node;

    /* Resolve the LENGTH field of an array here */
!   if (DECL_NAME (decl) == length_identifier_node && TYPE_ARRAY_P (type_found)
        && ! flag_emit_class_files && ! flag_emit_xref)
      {
        tree length = build_java_array_length_access (where_found);
--- 6613,6620 ----
      return error_mark_node;

    /* Resolve the LENGTH field of an array here */
!   if (DECL_P(decl) && DECL_NAME (decl) == length_identifier_node
!       && TYPE_ARRAY_P (type_found)
        && ! flag_emit_class_files && ! flag_emit_xref)
      {
        tree length = build_java_array_length_access (where_found);

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