diff options
author | Alexandre Petit-Bianco <apbianco@cygnus.com> | 2000-07-07 06:36:14 +0000 |
---|---|---|
committer | Alexandre Petit-Bianco <apbianco@gcc.gnu.org> | 2000-07-06 23:36:14 -0700 |
commit | 0c2b81459e5e8aa3d34f5deb4cc150a1ee8ee779 (patch) | |
tree | 9c3743be4380c260fc213732a10aaa7f6976cf6f /gcc/java/parse.c | |
parent | 98a52c2ccf0f7c28c910a2bc17d0e97ff9f28bdb (diff) | |
download | gcc-0c2b81459e5e8aa3d34f5deb4cc150a1ee8ee779.zip gcc-0c2b81459e5e8aa3d34f5deb4cc150a1ee8ee779.tar.gz gcc-0c2b81459e5e8aa3d34f5deb4cc150a1ee8ee779.tar.bz2 |
[multiple changes]
2000-07-06 Alexandre Petit-Bianco <apbianco@cygnus.com>
* parse.h (BUILD_PTR_FROM_NAME): Surround with a do/while
construct.
* parse.y (find_as_inner_class): Fixed typo.
(do_resolve_class): Explore enclosing contexts when searching for
innerclasses. Removed curly brackets around BUILD_PTR_FROM_NAME.
(check_inner_class_access): Check `decl' which can be null in case
of previous errors.
2000-07-05 Alexandre Petit-Bianco <apbianco@cygnus.com>
* java-tree.h (java_debug_context): Declared `extern.'
(safe_layout_class): Likewise.
* parse.y (resolve_field_access): Field must be `static' in order
to be replaced by its initial value. Added comments.
(find_applicable_accessible_methods_list): Fixed typo.
(find_most_specific_methods_list): Methods found in innerclasses
take over methods founds in the enclosing contexts.
(java_complete_tree): Loosen restrictions on the type of DECLs
that can be replaced by their initialization values.
(valid_ref_assignconv_cast_p): Removed call to `enclosing_context_p.'
(http://gcc.gnu.org/ml/gcc-patches/2000-07/msg00184.html)
From-SVN: r34895
Diffstat (limited to 'gcc/java/parse.c')
-rw-r--r-- | gcc/java/parse.c | 56 |
1 files changed, 38 insertions, 18 deletions
diff --git a/gcc/java/parse.c b/gcc/java/parse.c index 2910e44..14c4375 100644 --- a/gcc/java/parse.c +++ b/gcc/java/parse.c @@ -6169,8 +6169,8 @@ find_as_inner_class (enclosing, name, cl) { tree acc = NULL_TREE, decl = NULL_TREE, ptr; - for(qual = EXPR_WFL_QUALIFICATION (cl); qual && !decl; - qual = TREE_CHAIN (qual)) + for (qual = EXPR_WFL_QUALIFICATION (cl); qual && !decl; + qual = TREE_CHAIN (qual)) { acc = merge_qualified_name (acc, EXPR_WFL_NODE (TREE_PURPOSE (qual))); @@ -8136,6 +8136,15 @@ do_resolve_class (enclosing, class_type, decl, cl) if ((new_class_decl = find_as_inner_class (enclosing, class_type, cl))) return new_class_decl; + /* Explore enclosing contexts. */ + while (INNER_CLASS_DECL_P (enclosing)) + { + enclosing = DECL_CONTEXT (enclosing); + if ((new_class_decl = find_as_inner_class (enclosing, + class_type, cl))) + return new_class_decl; + } + /* Now go to the upper classes, bail out if necessary. */ enclosing = CLASSTYPE_SUPER (TREE_TYPE (enclosing)); if (!enclosing || enclosing == object_type_node) @@ -8148,9 +8157,7 @@ do_resolve_class (enclosing, class_type, decl, cl) } if (TREE_CODE (enclosing) == IDENTIFIER_NODE) - { - BUILD_PTR_FROM_NAME (name, enclosing); - } + BUILD_PTR_FROM_NAME (name, enclosing); else name = enclosing; enclosing = do_resolve_class (NULL, name, NULL, NULL); @@ -9475,6 +9482,8 @@ static void check_inner_class_access (decl, enclosing_type, cl) tree decl, enclosing_type, cl; { + if (!decl) + return; /* We don't issue an error message when CL is null. CL can be null as a result of processing a JDEP crafted by source_start_java_method for the purpose of patching its parm @@ -11438,10 +11447,13 @@ resolve_field_access (qual_wfl, field_decl, field_type) if (!type_found) type_found = DECL_CONTEXT (decl); is_static = JDECL_P (decl) && FIELD_STATIC (decl); - if (FIELD_FINAL (decl) + if (FIELD_FINAL (decl) && FIELD_STATIC (decl) && JPRIMITIVE_TYPE_P (TREE_TYPE (decl)) && DECL_INITIAL (decl)) { + /* When called on a FIELD_DECL of the right (primitive) + type, java_complete_tree will try to substitue the decl + for it's initial value. */ field_ref = java_complete_tree (decl); static_final_found = 1; } @@ -12812,7 +12824,7 @@ find_applicable_accessible_methods_list (lc, class, name, arglist) search_not_done++; hash_lookup (searched_classes, - (const hash_table_key) class, TRUE, NULL); + (const hash_table_key) class, TRUE, NULL); if (!CLASS_LOADED_P (class) && !CLASS_FROM_SOURCE_P (class)) { @@ -12966,19 +12978,27 @@ find_most_specific_methods_list (list) for (method = list; method; method = TREE_CHAIN (method)) { + tree method_v, current_v; /* Don't test a method against itself */ if (method == current) continue; - /* Compare arguments and location where method where declared */ - if (argument_types_convertible (TREE_VALUE (method), - TREE_VALUE (current)) - && valid_method_invocation_conversion_p - (DECL_CONTEXT (TREE_VALUE (method)), - DECL_CONTEXT (TREE_VALUE (current)))) + method_v = TREE_VALUE (method); + current_v = TREE_VALUE (current); + + /* Compare arguments and location where methods where declared */ + if (argument_types_convertible (method_v, current_v)) { - int v = ++DECL_SPECIFIC_COUNT (TREE_VALUE (current)); - max = (v > max ? v : max); + if (valid_method_invocation_conversion_p + (DECL_CONTEXT (method_v), DECL_CONTEXT (current_v)) + || (INNER_CLASS_TYPE_P (DECL_CONTEXT (current_v)) + && enclosing_context_p (DECL_CONTEXT (method_v), + DECL_CONTEXT (current_v)))) + { + int v = (DECL_SPECIFIC_COUNT (current_v) += + (INNER_CLASS_TYPE_P (DECL_CONTEXT (current_v)) ? 2 : 1)); + max = (v > max ? v : max); + } } } } @@ -13315,8 +13335,8 @@ java_complete_tree (node) tree node; { node = java_complete_lhs (node); - if (TREE_CODE (node) == VAR_DECL && FIELD_STATIC (node) - && FIELD_FINAL (node) && DECL_INITIAL (node) != NULL_TREE + if (JDECL_P (node) && FIELD_STATIC (node) && FIELD_FINAL (node) + && DECL_INITIAL (node) != NULL_TREE && !flag_emit_xref) { tree value = DECL_INITIAL (node); @@ -13782,6 +13802,7 @@ java_complete_lhs (node) case NEW_CLASS_EXPR: case CALL_EXPR: /* Complete function's argument(s) first */ + if (complete_function_arguments (node)) return error_mark_node; else @@ -14766,7 +14787,6 @@ valid_ref_assignconv_cast_p (source, dest, cast) if (TYPE_CLASS_P (dest)) return (source == dest || inherits_from_p (source, dest) - || enclosing_context_p (source, dest) || (cast && inherits_from_p (dest, source))); if (TYPE_INTERFACE_P (dest)) { |