OSDN Git Service

* class.c (build_class_ref): Wrap the primary class type in a
authornathan <nathan@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 8 Aug 2005 14:56:18 +0000 (14:56 +0000)
committernathan <nathan@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 8 Aug 2005 14:56:18 +0000 (14:56 +0000)
NOP_EXPR.
* parse.y (java_complete_lhs) <COMPONENT_REF case>: Extract the
primary class type from the NOP_EXPR in which it was placed.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@102859 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/java/ChangeLog
gcc/java/class.c
gcc/java/parse.y

index cd908fd..01d9a91 100644 (file)
@@ -1,3 +1,10 @@
+2005-08-08  Nathan Sidwell  <nathan@codesourcery.com>
+
+       * class.c (build_class_ref): Wrap the primary class type in a
+       NOP_EXPR.
+       * parse.y (java_complete_lhs) <COMPONENT_REF case>: Extract the
+       primary class type from the NOP_EXPR in which it was placed.
+
 2005-07-28  Diego Novillo  <dnovillo@redhat.com>
 
        * expr.c (expand_load_internal): Fix missing parens in
index c2bd62f..d7e22c2 100644 (file)
@@ -1011,6 +1011,11 @@ build_class_ref (tree type)
                abort ();
 
              prim_class = lookup_class (get_identifier (prim_class_name));
+             /* We wrap the class in a NOP_EXPR, because it is a
+                type.  We can't hold it in the COMPONENT_REF itself,
+                as that type must remain NULL.  */
+             prim_class = build1 (NOP_EXPR, prim_class, NULL_TREE);
+             
              return build3 (COMPONENT_REF, NULL_TREE,
                             prim_class, TYPE_identifier_node, NULL_TREE);
            }
index 10a37e0..82c156e 100644 (file)
@@ -12382,26 +12382,30 @@ java_complete_lhs (tree node)
 
     case COMPONENT_REF:
       /* The first step in the re-write of qualified name handling.  FIXME.
-        So far, this is only to support PRIMTYPE.class -> PRIMCLASS.TYPE. */
-      TREE_OPERAND (node, 0) = java_complete_tree (TREE_OPERAND (node, 0));
-      if (TREE_CODE (TREE_OPERAND (node, 0)) == RECORD_TYPE)
-       {
-         tree name = TREE_OPERAND (node, 1);
-         tree field = lookup_field_wrapper (TREE_OPERAND (node, 0), name);
-         if (field == NULL_TREE)
-           {
-             error ("missing static field %qs", IDENTIFIER_POINTER (name));
-             return error_mark_node;
-           }
-         if (! FIELD_STATIC (field))
-           {
-             error ("not a static field %qs", IDENTIFIER_POINTER (name));
-             return error_mark_node;
-           }
-         return field;
-       }
-      else
-       abort ();
+        So far, this is only to support PRIMTYPE.class ->
+        PRIMCLASS.TYPE. */
+      {
+       tree prim_class = TREE_OPERAND (node, 0);
+       tree name = TREE_OPERAND (node, 1);
+       tree field;
+       
+       gcc_assert (TREE_CODE (prim_class) == NOP_EXPR);
+       prim_class = java_complete_tree (TREE_TYPE (prim_class));
+       gcc_assert (TREE_CODE (prim_class) == RECORD_TYPE);
+       field = lookup_field_wrapper (prim_class, name);
+       
+       if (field == NULL_TREE)
+         {
+           error ("missing static field %qs", IDENTIFIER_POINTER (name));
+           return error_mark_node;
+         }
+       if (! FIELD_STATIC (field))
+         {
+           error ("not a static field %qs", IDENTIFIER_POINTER (name));
+           return error_mark_node;
+         }
+       return field;
+      }
       break;
 
     case THIS_EXPR: