Commit 82371d41 by Alexandre Petit-Bianco Committed by Alexandre Petit-Bianco

class.c (layout_class_method): Don't report error on non-static overriding…

class.c (layout_class_method): Don't report error on non-static overriding static if the method is private.

Tue Dec  1 13:53:24 1998  Alexandre Petit-Bianco  <apbianco@cygnus.com>
	* class.c (layout_class_method): Don't report error on non-static
 	overriding static if the method is private.
	* java-tree.h (finish_class): Prototype added.
	* lex.c (java_get_line_col): Handle col argument -2 value.
	* parse.h: All static method declarations moved to parse.y.
	* parse.y: Now contains all static method declarations previously
 	found in parse.h.
	(find_expr_with_wfl, missing_return_error,
 	unreachable_stmt_error): New functions.
	(java_get_real_method_name): Identify constructors bearing class
 	names in source code compiled classes only.
	(java_complete_expand_methods): Call missing_return_error.
	(invocation_mode): Private methods invoked as static methods.
	(java_complete_tree): Call unreachable_stmt_error.
This patch corrects the way unreachable statement and missing return
statement errors are reported. It also fixes random bugs.

From-SVN: r24036
parent df3ba30a
Tue Dec 1 13:53:24 1998 Alexandre Petit-Bianco <apbianco@cygnus.com>
* class.c (layout_class_method): Don't report error on non-static
overriding static if the method is private.
* java-tree.h (finish_class): Prototype added.
* lex.c (java_get_line_col): Handle col argument -2 value.
* parse.h: All static method declarations moved to parse.y.
* parse.y: Now contains all static method declarations previously
found in parse.h.
(find_expr_with_wfl, missing_return_error,
unreachable_stmt_error): New functions.
(java_get_real_method_name): Identify constructors bearing class
names in source code compiled classes only.
(java_complete_expand_methods): Call missing_return_error.
(invocation_mode): Private methods invoked as static methods.
(java_complete_tree): Call unreachable_stmt_error.
1998-12-01 Tom Tromey <tromey@cygnus.com>
* Makefile.in (+target): Removed.
......
......@@ -1588,7 +1588,8 @@ layout_class_method (this_class, super_class, method_decl, dtable_count)
if (super_method != NULL_TREE)
{
DECL_VINDEX (method_decl) = DECL_VINDEX (super_method);
if (DECL_VINDEX (method_decl) == NULL_TREE)
if (DECL_VINDEX (method_decl) == NULL_TREE &&
! TREE_PRIVATE (method_decl))
error_with_decl (method_decl,
"non-static method '%s' overrides static method");
#if 0
......
......@@ -561,6 +561,7 @@ extern char *print_int_node PROTO ((tree));
extern void parse_error_context VPROTO ((tree cl, char *msg, ...));
extern tree build_primtype_type_ref PROTO ((char *));
extern tree java_get_real_method_name PROTO ((tree));
extern void finish_class PROTO ((tree));
/* Access flags etc for a method (a FUNCTION_DECL): */
......
......@@ -1315,11 +1315,14 @@ java_get_line_col (filename, line, col)
/* Dumb implementation. Doesn't try to cache or optimize things. */
/* First line of the file is line 1, first column is 1 */
/* COL <= 0 means, at the CR/LF in LINE */
/* COL == -1 means, at the CR/LF in LINE */
/* COL == -2 means, at the first non space char in LINE */
FILE *fp;
int c, ccol, cline = 1;
int current_line_col = 0;
int first_non_space = 0;
char *base;
if (!(fp = fopen (filename, "r")))
fatal ("Can't open file - java_display_line_col");
......@@ -1343,6 +1346,8 @@ java_get_line_col (filename, line, col)
c = getc (fp);
if (c < 0 || java_is_eol (fp, c))
break;
if (!first_non_space && !JAVA_WHITE_SPACE_P (c))
first_non_space = current_line_col;
obstack_1grow (&temporary_obstack, c);
current_line_col++;
}
......@@ -1350,12 +1355,25 @@ java_get_line_col (filename, line, col)
obstack_1grow (&temporary_obstack, '\n');
if (col < 0)
col = current_line_col;
if (col == -1)
{
col = current_line_col;
first_non_space = 0;
}
else if (col == -2)
col = first_non_space;
else
first_non_space = 0;
/* Place the '^' a the right position */
base = obstack_base (&temporary_obstack);
for (ccol = 1; ccol <= col; ccol++)
obstack_1grow (&temporary_obstack, ' ');
{
/* Compute \t when reaching first_non_space */
char c = (first_non_space ?
(base [ccol-1] == '\t' ? '\t' : ' ') : ' ');
obstack_1grow (&temporary_obstack, c);
}
obstack_grow0 (&temporary_obstack, "^", 1);
fclose (fp);
......
......@@ -640,169 +640,7 @@ struct parser_ctxt {
#endif /* JC1_LITE */
};
/* Functions declarations */
#ifndef JC1_LITE
static char *java_accstring_lookup PROTO ((int));
static void classitf_redefinition_error PROTO ((char *,tree, tree, tree));
static void variable_redefinition_error PROTO ((tree, tree, tree, int));
static void check_modifiers PROTO ((char *, int, int));
static tree create_class PROTO ((int, tree, tree, tree));
static tree create_interface PROTO ((int, tree, tree));
static tree find_field PROTO ((tree, tree));
static tree lookup_field_wrapper PROTO ((tree, tree));
static int duplicate_declaration_error_p PROTO ((tree, tree, tree));
static void register_fields PROTO ((int, tree, tree));
static tree parser_qualified_classname PROTO ((tree));
static int parser_check_super PROTO ((tree, tree, tree));
static int parser_check_super_interface PROTO ((tree, tree, tree));
static void check_modifiers_consistency PROTO ((int));
static tree lookup_cl PROTO ((tree));
static tree lookup_java_method2 PROTO ((tree, tree, int));
static tree method_header PROTO ((int, tree, tree, tree));
static void fix_method_argument_names PROTO ((tree ,tree));
static tree method_declarator PROTO ((tree, tree));
static void parse_warning_context VPROTO ((tree cl, char *msg, ...));
static void issue_warning_error_from_context PROTO ((tree, char *msg, va_list));
static tree parse_jdk1_1_error PROTO ((char *));
static void complete_class_report_errors PROTO ((jdep *));
static int process_imports PROTO ((void));
static void read_import_dir PROTO ((tree));
static int find_in_imports_on_demand PROTO ((tree));
static int find_in_imports PROTO ((tree));
static int check_pkg_class_access PROTO ((tree, tree));
static tree resolve_package PROTO ((tree, tree *));
static tree lookup_package_type PROTO ((char *, int));
static tree resolve_class PROTO ((tree, tree, tree));
static tree do_resolve_class PROTO ((tree, tree, tree));
static void declare_local_variables PROTO ((int, tree, tree));
static void source_start_java_method PROTO ((tree));
static void source_end_java_method PROTO ((void));
static void expand_start_java_method PROTO ((tree));
static tree find_name_in_single_imports PROTO ((tree));
static void check_abstract_method_header PROTO ((tree));
static tree lookup_java_interface_method2 PROTO ((tree, tree));
static tree resolve_expression_name PROTO ((tree, tree *));
static tree maybe_create_class_interface_decl PROTO ((tree, tree, tree));
static int check_class_interface_creation PROTO ((int, int, tree,
tree, tree, tree));
static tree patch_method_invocation PROTO ((tree, tree, tree,
int *, tree *, int));
static int breakdown_qualified PROTO ((tree *, tree *, tree));
static tree resolve_and_layout PROTO ((tree, tree));
static tree resolve_no_layout PROTO ((tree, tree));
static int invocation_mode PROTO ((tree, int));
static tree find_applicable_accessible_methods_list PROTO ((int, tree,
tree, tree));
static tree find_most_specific_methods_list PROTO ((tree));
static int argument_types_convertible PROTO ((tree, tree));
static tree patch_invoke PROTO ((tree, tree, tree, int));
static tree lookup_method_invoke PROTO ((int, tree, tree, tree, tree));
static tree register_incomplete_type PROTO ((int, tree, tree, tree));
static tree obtain_incomplete_type PROTO ((tree));
static tree java_complete_tree PROTO ((tree));
static void java_complete_expand_method PROTO ((tree));
static int unresolved_type_p PROTO ((tree, tree *));
static void create_jdep_list PROTO ((struct parser_ctxt *));
static tree build_expr_block PROTO ((tree, tree));
static tree enter_block PROTO ((void));
static tree enter_a_block PROTO ((tree));
static tree exit_block PROTO ((void));
static tree lookup_name_in_blocks PROTO ((tree));
static void maybe_absorb_scoping_blocks PROTO ((void));
static tree build_method_invocation PROTO ((tree, tree));
static tree build_new_invocation PROTO ((tree, tree));
static tree build_assignment PROTO ((int, int, tree, tree));
static tree build_binop PROTO ((enum tree_code, int, tree, tree));
static int check_final_assignment PROTO ((tree ,tree));
static tree patch_assignment PROTO ((tree, tree, tree ));
static tree patch_binop PROTO ((tree, tree, tree));
static tree build_unaryop PROTO ((int, int, tree));
static tree build_incdec PROTO ((int, int, tree, int));
static tree patch_unaryop PROTO ((tree, tree));
static tree build_cast PROTO ((int, tree, tree));
static tree build_null_of_type PROTO ((tree));
static tree patch_cast PROTO ((tree, tree));
static int valid_ref_assignconv_cast_p PROTO ((tree, tree, int));
static int valid_builtin_assignconv_identity_widening_p PROTO ((tree, tree));
static int valid_cast_to_p PROTO ((tree, tree));
static int valid_method_invocation_conversion_p PROTO ((tree, tree));
static tree try_builtin_assignconv PROTO ((tree, tree, tree));
static tree try_reference_assignconv PROTO ((tree, tree));
static tree build_unresolved_array_type PROTO ((tree));
static tree build_array_from_name PROTO ((tree, tree, tree, tree *));
static tree build_array_ref PROTO ((int, tree, tree));
static tree patch_array_ref PROTO ((tree));
static tree make_qualified_name PROTO ((tree, tree, int));
static tree merge_qualified_name PROTO ((tree, tree));
static tree make_qualified_primary PROTO ((tree, tree, int));
static int resolve_qualified_expression_name PROTO ((tree, tree *,
tree *, tree *));
static void qualify_ambiguous_name PROTO ((tree));
static void maybe_generate_clinit PROTO ((void));
static tree resolve_field_access PROTO ((tree, tree *, tree *));
static tree build_newarray_node PROTO ((tree, tree, int));
static tree patch_newarray PROTO ((tree));
static tree resolve_type_during_patch PROTO ((tree));
static tree build_this PROTO ((int));
static tree build_return PROTO ((int, tree));
static tree patch_return PROTO ((tree));
static tree maybe_access_field PROTO ((tree, tree, tree));
static int complete_function_arguments PROTO ((tree));
static int check_for_static_method_reference PROTO ((tree, tree, tree, tree, tree));
static int not_accessible_p PROTO ((tree, tree, int));
static void check_deprecation PROTO ((tree, tree));
static int class_in_current_package PROTO ((tree));
static tree build_if_else_statement PROTO ((int, tree, tree, tree));
static tree patch_if_else_statement PROTO ((tree));
static tree add_stmt_to_compound PROTO ((tree, tree, tree));
static tree add_stmt_to_block PROTO ((tree, tree, tree));
static tree patch_exit_expr PROTO ((tree));
static tree build_labeled_block PROTO ((int, tree));
static tree generate_labeled_block PROTO (());
static tree complete_labeled_statement PROTO ((tree, tree));
static tree build_bc_statement PROTO ((int, int, tree));
static tree patch_bc_statement PROTO ((tree));
static tree patch_loop_statement PROTO ((tree));
static tree build_new_loop PROTO ((tree));
static tree build_loop_body PROTO ((int, tree, int));
static tree complete_loop_body PROTO ((int, tree, tree, int));
static tree build_debugable_stmt PROTO ((int, tree));
static tree complete_for_loop PROTO ((int, tree, tree, tree));
static tree patch_switch_statement PROTO ((tree));
static tree string_constant_concatenation PROTO ((tree, tree));
static tree build_string_concatenation PROTO ((tree, tree));
static tree patch_string_cst PROTO ((tree));
static tree patch_string PROTO ((tree));
static tree build_jump_to_finally PROTO ((tree, tree, tree, tree));
static tree build_try_statement PROTO ((int, tree, tree, tree));
static tree patch_try_statement PROTO ((tree));
static tree patch_synchronized_statement PROTO ((tree, tree));
static tree patch_throw_statement PROTO ((tree, tree));
static void check_thrown_exceptions PROTO ((int, tree));
static int check_thrown_exceptions_do PROTO ((tree));
static void purge_unchecked_exceptions PROTO ((tree));
static void check_throws_clauses PROTO ((tree, tree, tree));
static void complete_method_declaration PROTO ((tree));
static tree build_super_invocation PROTO (());
static int verify_constructor_circularity PROTO ((tree, tree));
static char *constructor_circularity_msg PROTO ((tree, tree));
static tree build_this_super_qualified_invocation PROTO ((int, tree, tree,
int, int));
static char *get_printable_method_name PROTO ((tree));
static tree patch_conditional_expr PROTO ((tree, tree, tree));
static void maybe_generate_finit PROTO (());
static void fix_constructors PROTO ((tree));
static int verify_constructor_super PROTO (());
static tree create_artificial_method PROTO ((tree, int, tree, tree, tree));
static void start_artificial_method_body PROTO ((tree));
static void end_artificial_method_body PROTO ((tree));
static tree generate_field_initialization_code PROTO ((tree));
static int check_method_redefinition PROTO ((tree, tree));
static int reset_method_name PROTO ((tree));
static void java_check_regular_methods PROTO ((tree));
static void java_check_abstract_methods PROTO ((tree));
static tree maybe_build_primttype_type_ref PROTO ((tree, tree));
void safe_layout_class PROTO ((tree));
void java_complete_class PROTO ((void));
void java_check_circular_reference PROTO ((void));
......@@ -813,10 +651,9 @@ char *java_get_line_col PROTO ((char *, int, int));
void java_expand_switch PROTO ((tree));
tree java_get_catch_block PROTO ((tree, int));
int java_report_errors PROTO (());
#endif /* JC1_LITE */
#endif
/* Always in use, no matter what you compile */
void java_push_parser_context PROTO ((void));
void java_pop_parser_context PROTO ((int));
void java_init_lex PROTO ((void));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment