aboutsummaryrefslogtreecommitdiff
path: root/gcc/java/verify.c
diff options
context:
space:
mode:
authorPer Bothner <bothner@gcc.gnu.org>1998-11-14 09:22:22 -0800
committerPer Bothner <bothner@gcc.gnu.org>1998-11-14 09:22:22 -0800
commit46cf461c83489859531d548d57e1751f8c5cb68c (patch)
treec372fadfdc48e2a6b988a0d96a60b47f714f4b8d /gcc/java/verify.c
parentbd8dc16507f210e0d01954e65e5d93061c560d5b (diff)
downloadgcc-46cf461c83489859531d548d57e1751f8c5cb68c.zip
gcc-46cf461c83489859531d548d57e1751f8c5cb68c.tar.gz
gcc-46cf461c83489859531d548d57e1751f8c5cb68c.tar.bz2
Allow uses of interface types to verify.
� Allow uses of interface types to verify. This is not really type-safe, but it matches what Sun does, and is OK as long as there are appropriate run-time checks. * verify.c (merge_types): If merging two interface types, just set the result to java.lang.Object. * expr.c (pop_type): Any interface is matches by java.lang.Object. From-SVN: r23656
Diffstat (limited to 'gcc/java/verify.c')
-rw-r--r--gcc/java/verify.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/gcc/java/verify.c b/gcc/java/verify.c
index d73c52a..9554a81 100644
--- a/gcc/java/verify.c
+++ b/gcc/java/verify.c
@@ -150,6 +150,32 @@ merge_types (type1, type2)
}
return object_ptr_type_node;
}
+
+ if (CLASS_INTERFACE (TYPE_NAME (tt1)))
+ {
+ if (CLASS_INTERFACE (TYPE_NAME (tt2)))
+ {
+ /* This is a kludge, but matches what Sun's verifier does.
+ It can be tricked, but is safe as long as type errors
+ (i.e. interface method calls) are caught at run-time. */
+ return object_ptr_type_node;
+ }
+ else
+ {
+ if (can_widen_reference_to (tt2, tt1))
+ return type1;
+ else
+ return TYPE_UNKNOWN;
+ }
+ }
+ else if (CLASS_INTERFACE (TYPE_NAME (tt2)))
+ {
+ if (can_widen_reference_to (tt1, tt2))
+ return type2;
+ else
+ return TYPE_UNKNOWN;
+ }
+
type1 = tt1;
type2 = tt2;