From 7e3e53bc047a1695b044e163a639556d768b8717 Mon Sep 17 00:00:00 2001 From: tromey Date: Mon, 24 Feb 2003 02:14:49 +0000 Subject: * lang-options.h: Added -Wdeprecated. * gcj.texi (Warnings): Document -Wdeprecated. * java-tree.h (flag_deprecated): Declare. * lang.c (lang_W_options): Added deprecated. (flag_deprecated): New global. * chartables.h: Rebuilt. * gen-table.pl (process_one): Look at whitespace. (print_tables): Define LETTER_SPACE, LETTER_MASK. * parse.h (CLEAR_DEPRECATED): New macro. (CHECK_DEPRECATED_NO_RESET): New macro. * jcf-parse.c (handle_deprecated): New function. (HANDLE_DEPRECATED_ATTRIBUTE): New define. * jcf-reader.c (get_attribute): Handle Deprecated attribute. * parse.y (resolve_type_during_patch): Check deprecation. (jdep_resolve_class): Likewise. (process_imports): Likewise. (resolve_expression_name): Likewise. (check_deprecation): Strip arrays from decl. Check flag_deprecated. (patch_method_invocation): Also check the particular constructor for deprecation. (register_fields): Use CHECK_DEPRECATED_NO_RESET in loop. * jcf-write.c (append_deprecated_attribute): New function. (generate_classfile): Generate deprecated attribute when appropriate. * lex.c (java_parse_doc_section): Return type now void. Rewrote. (java_lex) [case '*']: Simplify logic. (java_start_char_p): Use LETTER_MASK. (java_part_char_p): Likewise. (java_space_char_p): New function. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@63350 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/java/jcf-write.c | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) (limited to 'gcc/java/jcf-write.c') diff --git a/gcc/java/jcf-write.c b/gcc/java/jcf-write.c index 1ddc1a05730..583cff929c6 100644 --- a/gcc/java/jcf-write.c +++ b/gcc/java/jcf-write.c @@ -341,6 +341,7 @@ static void emit_jsr (struct jcf_block *, struct jcf_partial *); static void call_cleanups (struct jcf_block *, struct jcf_partial *); static char *make_class_file_name (tree); static unsigned char *append_synthetic_attribute (struct jcf_partial *); +static void append_deprecated_attribute (struct jcf_partial *); static void append_innerclasses_attribute (struct jcf_partial *, tree); static void append_innerclasses_attribute_entry (struct jcf_partial *, tree, tree); static void append_gcj_attribute (struct jcf_partial *, tree); @@ -2871,8 +2872,11 @@ generate_classfile (tree clas, struct jcf_partial *state) if (have_value) attr_count++; - if (FIELD_THISN (part) || FIELD_LOCAL_ALIAS (part) || FIELD_SYNTHETIC (part)) + if (FIELD_THISN (part) || FIELD_LOCAL_ALIAS (part) + || FIELD_SYNTHETIC (part)) attr_count++; + if (FIELD_DEPRECATED (part)) + attr_count++; PUT2 (attr_count); /* attributes_count */ if (have_value) @@ -2894,6 +2898,8 @@ generate_classfile (tree clas, struct jcf_partial *state) if (FIELD_THISN (part) || FIELD_LOCAL_ALIAS (part) || FIELD_SYNTHETIC (part)) ptr = append_synthetic_attribute (state); + if (FIELD_DEPRECATED (part)) + append_deprecated_attribute (state); fields_count++; } ptr = fields_count_ptr; UNSAFE_PUT2 (fields_count); @@ -2929,6 +2935,9 @@ generate_classfile (tree clas, struct jcf_partial *state) i++; synthetic_p = 1; } + /* Make room for Deprecated attribute. */ + if (METHOD_DEPRECATED (part)) + i++; PUT2 (i); /* attributes_count */ @@ -3069,6 +3078,10 @@ generate_classfile (tree clas, struct jcf_partial *state) PUT2 (i); } } + + if (METHOD_DEPRECATED (part)) + append_deprecated_attribute (state); + methods_count++; current_function_decl = save_function; } @@ -3092,6 +3105,9 @@ generate_classfile (tree clas, struct jcf_partial *state) i++; PUT2 (i); /* attributes_count */ + if (CLASS_DEPRECATED (TYPE_NAME (clas))) + i++; + /* generate the SourceFile attribute. */ if (SourceFile_node == NULL_TREE) { @@ -3105,6 +3121,8 @@ generate_classfile (tree clas, struct jcf_partial *state) PUT2 (i); append_gcj_attribute (state, clas); append_innerclasses_attribute (state, clas); + if (CLASS_DEPRECATED (TYPE_NAME (clas))) + append_deprecated_attribute (state); /* New finally generate the contents of the constant pool chunk. */ i = count_constant_pool_bytes (&state->cpool); @@ -3133,6 +3151,17 @@ append_synthetic_attribute (struct jcf_partial *state) return ptr; } +static void +append_deprecated_attribute (struct jcf_partial *state) +{ + unsigned char *ptr = append_chunk (NULL, 6, state); + int i; + + i = find_utf8_constant (&state->cpool, get_identifier ("Deprecated")); + PUT2 (i); /* Attribute string index */ + PUT4 (0); /* Attribute length */ +} + static void append_gcj_attribute (struct jcf_partial *state, tree class) { -- cgit v1.2.1