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 | |
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')
-rw-r--r-- | gcc/java/ChangeLog | 23 | ||||
-rw-r--r-- | gcc/java/java-tree.h | 4 | ||||
-rw-r--r-- | gcc/java/parse.c | 56 | ||||
-rw-r--r-- | gcc/java/parse.h | 4 | ||||
-rw-r--r-- | gcc/java/parse.y | 55 |
5 files changed, 102 insertions, 40 deletions
diff --git a/gcc/java/ChangeLog b/gcc/java/ChangeLog index e6deecd..03fb4f3 100644 --- a/gcc/java/ChangeLog +++ b/gcc/java/ChangeLog @@ -1,3 +1,26 @@ +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.' + 2000-07-05 Tom Tromey <tromey@cygnus.com> * Make-lang.in (PARSE_DIR): New macro. diff --git a/gcc/java/java-tree.h b/gcc/java/java-tree.h index 2f1bbec..5d132be 100644 --- a/gcc/java/java-tree.h +++ b/gcc/java/java-tree.h @@ -779,8 +779,8 @@ extern const char* open_class PARAMS ((const char *, struct JCF *, int, const char *)); # endif /* JCF_USE_STDIO */ #endif -void java_debug_context PARAMS ((void)); -void safe_layout_class PARAMS ((tree)); +extern void java_debug_context PARAMS ((void)); +extern void safe_layout_class PARAMS ((tree)); extern tree get_boehm_type_descriptor PARAMS ((tree)); extern unsigned long java_hash_hash_tree_node PARAMS ((hash_table_key)); 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)) { diff --git a/gcc/java/parse.h b/gcc/java/parse.h index 45573fb..687dc95 100644 --- a/gcc/java/parse.h +++ b/gcc/java/parse.h @@ -156,10 +156,10 @@ extern tree stabilize_reference PARAMS ((tree)); /* Quickly build a temporary pointer on hypothetical type NAME. */ #define BUILD_PTR_FROM_NAME(ptr, name) \ - { \ + do { \ ptr = build (POINTER_TYPE, NULL_TREE); \ TYPE_NAME (ptr) = name; \ - } + } while (0) #define INCOMPLETE_TYPE_P(NODE) \ ((TREE_CODE (NODE) == POINTER_TYPE) \ diff --git a/gcc/java/parse.y b/gcc/java/parse.y index 42274e6..312afd3 100644 --- a/gcc/java/parse.y +++ b/gcc/java/parse.y @@ -3471,8 +3471,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))); @@ -5438,6 +5438,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) @@ -5450,9 +5459,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); @@ -6777,6 +6784,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 @@ -8740,10 +8749,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; } @@ -10114,7 +10126,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)) { @@ -10268,19 +10280,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); + } } } } @@ -10617,8 +10637,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); @@ -12068,7 +12088,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)) { |