aboutsummaryrefslogtreecommitdiff
path: root/gcc/java/parse.y
diff options
context:
space:
mode:
authorAlexandre Petit-Bianco <apbianco@gcc.gnu.org>2000-03-06 22:25:14 -0800
committerAlexandre Petit-Bianco <apbianco@gcc.gnu.org>2000-03-06 22:25:14 -0800
commit614eaae0a5de347b8fed549b0acdab2ef1b141d9 (patch)
tree21007f6e90dfbf502b8219c186d62fdeefad01e2 /gcc/java/parse.y
parent141b58108437ef9f1984b78f194933f5b68bab22 (diff)
downloadgcc-614eaae0a5de347b8fed549b0acdab2ef1b141d9.zip
gcc-614eaae0a5de347b8fed549b0acdab2ef1b141d9.tar.gz
gcc-614eaae0a5de347b8fed549b0acdab2ef1b141d9.tar.bz2
[multiple changes]
2000-03-06 Bryce McKinlay <bryce@albatross.co.nz> * typeck.c (lookup_do): Search superinterfaces first when looking up an interface method. From Godmar Back <gback@cs.utah.edu> 2000-03-02 Alexandre Petit-Bianco <apbianco@cygnus.com> * java-tree.h (lookup_argument_method2): Declared. (safe_layout_class): Prototype moved from parse.h. * parse.h (safe_layout_class): Prototype moved to java-tree.h. * parse.y (java_check_regular_methods): Local `super_class' gone. Call lookup_argument_method2 instead of lookup_argument_method. Perform modifier match for methods found declared in implemented interfaces. Fixed indentation problem. Overriding/hiding error report to take place only for methods found in classes. * typeck.c (lookup_argument_method): Changed leading comment. Re-written by calling lookup_do. (lookup_argument_method2): New function. (lookup_java_method): Re-written by calling lookup_do. (lookup_do): New function. From-SVN: r32376
Diffstat (limited to 'gcc/java/parse.y')
-rw-r--r--gcc/java/parse.y37
1 files changed, 26 insertions, 11 deletions
diff --git a/gcc/java/parse.y b/gcc/java/parse.y
index 35ab269..5406a3b 100644
--- a/gcc/java/parse.y
+++ b/gcc/java/parse.y
@@ -4762,7 +4762,7 @@ check_abstract_method_definitions (do_interface, class_decl, type)
}
}
-/* Check that CLASS_DECL somehoow implements all inherited abstract
+/* Check that CLASS_DECL somehow implements all inherited abstract
methods. */
static void
@@ -4807,7 +4807,6 @@ java_check_regular_methods (class_decl)
int saw_constructor = 0;
tree method;
tree class = CLASS_TO_HANDLE_TYPE (TREE_TYPE (class_decl));
- tree super_class = CLASSTYPE_SUPER (class);
tree saved_found_wfl = NULL_TREE, found = NULL_TREE;
tree mthrows;
@@ -4859,7 +4858,7 @@ java_check_regular_methods (class_decl)
}
sig = build_java_argument_signature (TREE_TYPE (method));
- found = lookup_argument_method (super_class, DECL_NAME (method), sig);
+ found = lookup_argument_method2 (class, DECL_NAME (method), sig);
/* Nothing overrides or it's a private method. */
if (!found)
@@ -4875,12 +4874,25 @@ java_check_regular_methods (class_decl)
saved_found_wfl = DECL_NAME (found);
reset_method_name (found);
+ /* If `found' is declared in an interface, make sure the
+ modifier matches. */
+ if (CLASS_INTERFACE (TYPE_NAME (DECL_CONTEXT (found)))
+ && clinit_identifier_node != DECL_NAME (found)
+ && !METHOD_PUBLIC (method))
+ {
+ tree found_decl = TYPE_NAME (DECL_CONTEXT (found));
+ parse_error_context (method_wfl, "Class `%s' must override `%s' with a public method in order to implement interface `%s'",
+ IDENTIFIER_POINTER (DECL_NAME (class_decl)),
+ lang_printable_name (method, 0),
+ IDENTIFIER_POINTER (DECL_NAME (found_decl)));
+ }
+
/* Can't override a method with the same name and different return
types. */
if (TREE_TYPE (TREE_TYPE (found)) != TREE_TYPE (TREE_TYPE (method)))
{
- char *t = xstrdup (lang_printable_name (TREE_TYPE (TREE_TYPE (found)),
- 0));
+ char *t = xstrdup
+ (lang_printable_name (TREE_TYPE (TREE_TYPE (found)), 0));
parse_error_context
(method_wfl,
"Method `%s' was defined with return type `%s' in class `%s'",
@@ -4943,12 +4955,15 @@ java_check_regular_methods (class_decl)
- Overriding/hiding protected must be protected or public
- If the overriden or hidden method has default (package)
access, then the overriding or hiding method must not be
- private; otherwise, a compile-time error occurs */
- if ((METHOD_PUBLIC (found) && !METHOD_PUBLIC (method))
- || (METHOD_PROTECTED (found)
- && !(METHOD_PUBLIC (method) || METHOD_PROTECTED (method)))
- || (!(aflags & (ACC_PUBLIC | ACC_PRIVATE | ACC_STATIC))
- && METHOD_PRIVATE (method)))
+ private; otherwise, a compile-time error occurs. If
+ `found' belongs to an interface, things have been already
+ taken care of. */
+ if (!CLASS_INTERFACE (TYPE_NAME (DECL_CONTEXT (found)))
+ && ((METHOD_PUBLIC (found) && !METHOD_PUBLIC (method))
+ || (METHOD_PROTECTED (found)
+ && !(METHOD_PUBLIC (method) || METHOD_PROTECTED (method)))
+ || (!(aflags & (ACC_PUBLIC | ACC_PRIVATE | ACC_STATIC))
+ && METHOD_PRIVATE (method))))
{
parse_error_context
(method_wfl,