aboutsummaryrefslogtreecommitdiff
path: root/gcc/java/parse.y
diff options
context:
space:
mode:
authorTom Tromey <tromey@redhat.com>2003-02-24 02:14:49 +0000
committerTom Tromey <tromey@gcc.gnu.org>2003-02-24 02:14:49 +0000
commitf94ae54025ed8721d16c5e514797af4edaf850ba (patch)
treed282aebf536e61a47d7f1fade565cbb3e83027e2 /gcc/java/parse.y
parent804b2c48eab2cb65fb0ae268c8a40e91c24777ff (diff)
downloadgcc-f94ae54025ed8721d16c5e514797af4edaf850ba.zip
gcc-f94ae54025ed8721d16c5e514797af4edaf850ba.tar.gz
gcc-f94ae54025ed8721d16c5e514797af4edaf850ba.tar.bz2
lang-options.h: Added -Wdeprecated.
* 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. From-SVN: r63350
Diffstat (limited to 'gcc/java/parse.y')
-rw-r--r--gcc/java/parse.y53
1 files changed, 43 insertions, 10 deletions
diff --git a/gcc/java/parse.y b/gcc/java/parse.y
index 480668e..6745cec 100644
--- a/gcc/java/parse.y
+++ b/gcc/java/parse.y
@@ -4289,7 +4289,7 @@ register_fields (int flags, tree type, tree variable_list)
else
lineno = EXPR_WFL_LINENO (cl);
field_decl = add_field (class_type, current_name, real_type, flags);
- CHECK_DEPRECATED (field_decl);
+ CHECK_DEPRECATED_NO_RESET (field_decl);
/* If the field denotes a final instance variable, then we
allocate a LANG_DECL_SPECIFIC part to keep track of its
@@ -4347,6 +4347,8 @@ register_fields (int flags, tree type, tree variable_list)
DECL_INITIAL (field_decl) = TREE_OPERAND (init, 1);
}
}
+
+ CLEAR_DEPRECATED;
lineno = saved_lineno;
}
@@ -5460,6 +5462,10 @@ jdep_resolve_class (jdep *dep)
decl = resolve_class (JDEP_ENCLOSING (dep), JDEP_TO_RESOLVE (dep),
JDEP_DECL (dep), JDEP_WFL (dep));
JDEP_RESOLVED (dep, decl);
+ /* If there is no WFL, that's ok. We generate this warning
+ elsewhere. */
+ if (JDEP_WFL (dep) != NULL_TREE)
+ check_deprecation (JDEP_WFL (dep), decl);
}
if (!decl)
@@ -6647,7 +6653,11 @@ process_imports (void)
/* We found it, we can bail out */
if (IDENTIFIER_CLASS_VALUE (to_be_found))
- break;
+ {
+ check_deprecation (TREE_PURPOSE (import),
+ IDENTIFIER_CLASS_VALUE (to_be_found));
+ break;
+ }
/* We haven't found it. Maybe we're trying to access an
inner class. The only way for us to know is to try again
@@ -9154,6 +9164,8 @@ resolve_expression_name (tree id, tree *orig)
if (FIELD_LOCAL_ALIAS_USED (decl))
name = DECL_NAME (decl);
+ check_deprecation (id, decl);
+
/* Instance variable (8.3.1.1) can't appear within
static method, static initializer or initializer for
a static variable. */
@@ -9952,22 +9964,40 @@ not_accessible_p (tree reference, tree member, tree where, int from_super)
static void
check_deprecation (tree wfl, tree decl)
{
- const char *file = DECL_SOURCE_FILE (decl);
+ const char *file;
+ tree elt;
+
+ if (! flag_deprecated)
+ return;
+
+ /* We want to look at the element type of arrays here, so we strip
+ all surrounding array types. */
+ if (TYPE_ARRAY_P (TREE_TYPE (decl)))
+ {
+ elt = TREE_TYPE (decl);
+ while (TYPE_ARRAY_P (elt))
+ elt = TYPE_ARRAY_ELEMENT (elt);
+ /* We'll end up with a pointer type, so we use TREE_TYPE to go
+ to the record. */
+ decl = TYPE_NAME (TREE_TYPE (elt));
+ }
+ file = DECL_SOURCE_FILE (decl);
+
/* Complain if the field is deprecated and the file it was defined
in isn't compiled at the same time the file which contains its
use is */
if (DECL_DEPRECATED (decl)
&& !IS_A_COMMAND_LINE_FILENAME_P (get_identifier (file)))
{
- char the [20];
+ const char *the;
switch (TREE_CODE (decl))
{
case FUNCTION_DECL:
- strcpy (the, "method");
+ the = "method";
break;
case FIELD_DECL:
case VAR_DECL:
- strcpy (the, "field");
+ the = "field";
break;
case TYPE_DECL:
parse_warning_context (wfl, "The class `%s' has been deprecated",
@@ -10336,11 +10366,10 @@ patch_method_invocation (tree patch, tree primary, tree where, int from_super,
}
/* Deprecation check: check whether the method being invoked or the
- instance-being-created's type are deprecated. */
+ instance-being-created's type are deprecated. */
if (TREE_CODE (patch) == NEW_CLASS_EXPR)
check_deprecation (wfl, TYPE_NAME (DECL_CONTEXT (list)));
- else
- check_deprecation (wfl, list);
+ check_deprecation (wfl, list);
/* If invoking a innerclass constructor, there are hidden parameters
to pass */
@@ -13383,7 +13412,7 @@ patch_binop (tree node, tree wfl_op1, tree wfl_op2)
}
break;
- /* 15.19.1 Type Comparison Operator instaceof */
+ /* 15.19.1 Type Comparison Operator instanceof */
case INSTANCEOF_EXPR:
TREE_TYPE (node) = boolean_type_node;
@@ -14134,10 +14163,14 @@ resolve_type_during_patch (tree type)
IDENTIFIER_POINTER (EXPR_WFL_NODE (type)));
return NULL_TREE;
}
+
+ check_deprecation (type, type_decl);
+
return TREE_TYPE (type_decl);
}
return type;
}
+
/* 5.5 Casting Conversion. error_mark_node is returned if an error is
found. Otherwise NODE or something meant to replace it is returned. */