summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathan Sidwell <nathan@codesourcery.com>2005-08-08 14:56:18 +0000
committerNathan Sidwell <nathan@gcc.gnu.org>2005-08-08 14:56:18 +0000
commit063fb392d218bfecd0d60dc790a94cf7208b92aa (patch)
tree286bf4d6e59159e3c998a456c121a115c046e034
parentf303a996311673f8c9178f6593bf4c804077a8ec (diff)
downloadgcc-063fb392d218bfecd0d60dc790a94cf7208b92aa.tar.gz
class.c (build_class_ref): Wrap the primary class type in a NOP_EXPR.
* 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. From-SVN: r102859
-rw-r--r--gcc/java/ChangeLog7
-rw-r--r--gcc/java/class.c5
-rw-r--r--gcc/java/parse.y44
3 files changed, 36 insertions, 20 deletions
diff --git a/gcc/java/ChangeLog b/gcc/java/ChangeLog
index cd908fd672a..01d9a916a95 100644
--- a/gcc/java/ChangeLog
+++ b/gcc/java/ChangeLog
@@ -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
diff --git a/gcc/java/class.c b/gcc/java/class.c
index c2bd62f7a73..d7e22c2fccf 100644
--- a/gcc/java/class.c
+++ b/gcc/java/class.c
@@ -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);
}
diff --git a/gcc/java/parse.y b/gcc/java/parse.y
index 10a37e0e449..82c156e7517 100644
--- a/gcc/java/parse.y
+++ b/gcc/java/parse.y
@@ -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: