This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
Re: Patch: fix gcj deprecation support
- From: Tom Tromey <tromey at redhat dot com>
- To: Eric Blake <ebb9 at email dot byu dot edu>
- Cc: java-patches at gcc dot gnu dot org, Gcc Patch List <gcc-patches at gcc dot gnu dot org>
- Date: 22 Feb 2003 21:58:23 -0700
- Subject: Re: Patch: fix gcj deprecation support
- References: <87y949csua.fsf@fleche.redhat.com><3E5704D4.4060108@email.byu.edu>
- Reply-to: tromey at redhat dot com
>>>>> "Eric" == Eric Blake <ebb9 at email dot byu dot edu> writes:
Eric> Have you run the Jacks tests on deprecation in
Eric> jvms/class-file-format/attributes/deprecated-attribute?
I had, but only to verify there weren't any regressions.
Inspired by your note, I looked at the tests and fixed all the bugs
that were reasonably fixable. The remaining problems seem to require
some out-of-band collaboration between the parser and the lexer; this
is sufficiently difficult that I didn't try it today. Also
4.7.10-jvms-class-18 fails due to a bug in name resolution; this is
outside the scope of what I was interested in working on today.
New patch appended. Tested on x86 Red Hat Linux 7.3; rebuilt libgcj;
no regressions.
This patch does much more. In particular it changes the .class file
reader to read the Deprecated attribute and it adds a -Wdeprecated
command-line option.
Incidentally, Jacks passes `-deprecation' to the javac it invokes.
This doesn't work properly with gcj. It seems to me that this is
another case where a `javac'-like wrapper would make things easier for
us; I didn't try to fix this problem, since for use -Wdeprecated is
the default.
Ok?
Tom
Index: gcc/java/ChangeLog
from Tom Tromey <tromey at redhat dot com>
* 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.
* 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.
Index: gcc/java/gcj.texi
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/gcj.texi,v
retrieving revision 1.42.4.7
diff -u -r1.42.4.7 gcj.texi
--- gcc/java/gcj.texi 4 Feb 2003 01:55:43 -0000 1.42.4.7
+++ gcc/java/gcj.texi 23 Feb 2003 04:54:56 -0000
@@ -338,6 +338,9 @@
newer than its matching class file. By default @command{gcj} will warn
about this.
+ at item -Wno-deprecated
+Warn if a deprecated class, method, or field is referred to.
+
@item -Wunused
This is the same as @command{gcc}'s @code{-Wunused}.
Index: gcc/java/gen-table.pl
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/gen-table.pl,v
retrieving revision 1.4
diff -u -r1.4 gen-table.pl
--- gcc/java/gen-table.pl 29 Dec 2001 04:31:10 -0000 1.4
+++ gcc/java/gen-table.pl 23 Feb 2003 04:54:56 -0000
@@ -1,6 +1,6 @@
#! /usr/bin/perl
-# Copyright (C) 2000, 2001 Free Software Foundation
+# Copyright (C) 2000, 2001, 2003 Free Software Foundation
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -130,7 +130,7 @@
{
my ($code, @fields) = @_;
- my $value = '';
+ my @value = ();
my $type = $fields[$CATEGORY];
# See if the character is a valid identifier start.
@@ -138,7 +138,7 @@
|| $type eq 'Pc' # Connecting punctuation
|| $type eq 'Sc') # Currency symbol
{
- $value = 'LETTER_START';
+ push (@value, 'LETTER_START');
}
# See if the character is a valid identifier member.
@@ -159,23 +159,29 @@
&& $code <= 0x206f)
|| $code == 0xfeff) # ZWNBSP
{
- if ($value eq '')
- {
- $value = 'LETTER_PART';
- }
- else
- {
- $value = 'LETTER_PART | ' . $value;
- }
+ push (@value, 'LETTER_PART');
+ }
+
+ if (($type =~ /Z./
+ # Java treats some values specially as non-spaces.
+ && $code != 0x00a0
+ && $code != 0x2007
+ && $code != 0x202f)
+ # And for our purposes there are some that should be specially
+ # treated as spaces.
+ || $code == 0x000b
+ || ($code >= 0x001c && $code <= 0x001f))
+ {
+ push (@value, 'LETTER_SPACE');
}
- if ($value eq '')
+ if (! @value)
{
$value = '0';
}
else
{
- $value = '(' . $value . ')';
+ $value = '(' . join (' | ', @value) . ')';
}
$map[$code] = $value;
@@ -196,7 +202,9 @@
print OUT "#define GCC_CHARTABLES_H\n\n";
print OUT "#define LETTER_START 1\n";
- print OUT "#define LETTER_PART 2\n\n";
+ print OUT "#define LETTER_PART 2\n";
+ print OUT "#define LETTER_SPACE 4\n\n";
+ print OUT "#define LETTER_MASK 7\n\n";
for ($count = 0; $count <= $last; $count += 256)
{
Index: gcc/java/java-tree.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/java-tree.h,v
retrieving revision 1.163
diff -u -r1.163 java-tree.h
--- gcc/java/java-tree.h 18 Nov 2002 18:13:35 -0000 1.163
+++ gcc/java/java-tree.h 23 Feb 2003 04:54:57 -0000
@@ -1,6 +1,6 @@
/* Definitions for parsing and type checking for the GNU compiler for
the Java(TM) language.
- Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002
+ Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003
Free Software Foundation, Inc.
This file is part of GNU CC.
@@ -172,6 +172,9 @@
/* When nonzero, report the now deprecated empty statements. */
extern int flag_extraneous_semicolon;
+
+/* When nonzero, report use of deprecated classes, methods, or fields. */
+extern int flag_deprecated;
/* When nonzero, always check for a non gcj generated classes archive. */
Index: gcc/java/jcf-parse.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/jcf-parse.c,v
retrieving revision 1.124.2.2
diff -u -r1.124.2.2 jcf-parse.c
--- gcc/java/jcf-parse.c 3 Feb 2003 14:06:32 -0000 1.124.2.2
+++ gcc/java/jcf-parse.c 23 Feb 2003 04:54:57 -0000
@@ -97,6 +97,7 @@
static void parse_source_file_2 PARAMS ((void));
static void parse_source_file_3 PARAMS ((void));
static void parse_class_file PARAMS ((void));
+static void handle_deprecated PARAMS ((void));
static void set_source_filename PARAMS ((JCF *, int));
static void ggc_mark_jcf PARAMS ((void**));
static void jcf_parse PARAMS ((struct JCF*));
@@ -125,6 +126,23 @@
}
}
+/* Handle "Deprecated" attribute. */
+static void
+handle_deprecated ()
+{
+ if (current_field != NULL_TREE)
+ FIELD_DEPRECATED (current_field) = 1;
+ else if (current_method != NULL_TREE)
+ METHOD_DEPRECATED (current_method) = 1;
+ else if (current_class != NULL_TREE)
+ CLASS_DEPRECATED (TYPE_NAME (current_class)) = 1;
+ else
+ {
+ /* Shouldn't happen. */
+ abort ();
+ }
+}
+
/* Handle "SourceFile" attribute. */
static void
@@ -220,6 +238,8 @@
} \
DECL_FUNCTION_THROWS (current_method) = nreverse (list); \
}
+
+#define HANDLE_DEPRECATED_ATTRIBUTE() handle_deprecated ()
/* Link seen inner classes to their outer context and register the
inner class to its outer context. They will be later loaded. */
Index: gcc/java/jcf-reader.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/jcf-reader.c,v
retrieving revision 1.16
diff -u -r1.16 jcf-reader.c
--- gcc/java/jcf-reader.c 25 Nov 2002 14:22:06 -0000 1.16
+++ gcc/java/jcf-reader.c 23 Feb 2003 04:54:57 -0000
@@ -2,7 +2,7 @@
It is not stand-alone: It depends on tons of macros, and the
intent is you #include this file after you've defined the macros.
- Copyright (C) 1996, 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
+ Copyright (C) 1996, 1997, 1998, 1999, 2000, 2003 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -222,6 +222,13 @@
if (MATCH_ATTRIBUTE ("gnu.gcj.gcj-compiled"))
{
HANDLE_GCJCOMPILED_ATTRIBUTE ();
+ }
+ else
+#endif
+#ifdef HANDLE_DEPRECATED_ATTRIBUTE
+ if (MATCH_ATTRIBUTE ("Deprecated"))
+ {
+ HANDLE_DEPRECATED_ATTRIBUTE ();
}
else
#endif
Index: gcc/java/jcf-write.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/jcf-write.c,v
retrieving revision 1.110.2.2
diff -u -r1.110.2.2 jcf-write.c
--- gcc/java/jcf-write.c 24 Jan 2003 23:15:30 -0000 1.110.2.2
+++ gcc/java/jcf-write.c 23 Feb 2003 04:54:58 -0000
@@ -1,5 +1,6 @@
/* Write out a Java(TM) class file.
- Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
+ Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003
+ Free Software Foundation, Inc.
This file is part of GNU CC.
@@ -343,6 +344,7 @@
static void call_cleanups PARAMS ((struct jcf_block *, struct jcf_partial *));
static char *make_class_file_name PARAMS ((tree));
static unsigned char *append_synthetic_attribute PARAMS ((struct jcf_partial *));
+static void append_deprecated_attribute PARAMS ((struct jcf_partial *));
static void append_innerclasses_attribute PARAMS ((struct jcf_partial *, tree));
static void append_innerclasses_attribute_entry PARAMS ((struct jcf_partial *, tree, tree));
static void append_gcj_attribute PARAMS ((struct jcf_partial *, tree));
@@ -2967,7 +2969,10 @@
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 */
@@ -2990,6 +2995,8 @@
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);
@@ -3025,6 +3032,9 @@
i++;
synthetic_p = 1;
}
+ /* Make room for Deprecated attribute. */
+ if (METHOD_DEPRECATED (part))
+ i++;
PUT2 (i); /* attributes_count */
@@ -3165,6 +3175,10 @@
PUT2 (i);
}
}
+
+ if (METHOD_DEPRECATED (part))
+ append_deprecated_attribute (state);
+
methods_count++;
current_function_decl = save_function;
}
@@ -3186,6 +3200,9 @@
i++;
if (clas == object_type_node)
i++;
+ if (CLASS_DEPRECATED (TYPE_NAME (clas)))
+ i++;
+
PUT2 (i); /* attributes_count */
/* generate the SourceFile attribute. */
@@ -3201,6 +3218,8 @@
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);
@@ -3228,6 +3247,18 @@
PUT4 (0); /* Attribute length */
return ptr;
+}
+
+static void
+append_deprecated_attribute (state)
+ 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
Index: gcc/java/lang-options.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/lang-options.h,v
retrieving revision 1.31
diff -u -r1.31 lang-options.h
--- gcc/java/lang-options.h 3 Mar 2002 08:35:11 -0000 1.31
+++ gcc/java/lang-options.h 23 Feb 2003 04:54:58 -0000
@@ -1,5 +1,5 @@
/* Switch definitions for the GNU compiler for the Java(TM) language.
- Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
+ Copyright (C) 1998, 1999, 2000, 2001, 2003 Free Software Foundation, Inc.
This file is part of GNU CC.
@@ -54,6 +54,8 @@
N_("Warn if deprecated empty statements are found") },
{ "-Wout-of-date",
N_("Warn if .class files are out of date") },
+ { "-Wdeprecated",
+ N_("Warn if deprecated class, method, or field is used") },
{ "-fforce-classes-archive-check",
N_("Always check for non gcj generated classes archives") },
{ "-fno-optimize-static-class-initialization",
Index: gcc/java/lang.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/lang.c,v
retrieving revision 1.114.2.1
diff -u -r1.114.2.1 lang.c
--- gcc/java/lang.c 5 Jan 2003 15:03:25 -0000 1.114.2.1
+++ gcc/java/lang.c 23 Feb 2003 04:54:58 -0000
@@ -1,5 +1,5 @@
/* Java(TM) language-specific utility routines.
- Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002
+ Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
Free Software Foundation, Inc.
This file is part of GNU CC.
@@ -174,6 +174,9 @@
/* When nonzero, report the now deprecated empty statements. */
int flag_extraneous_semicolon;
+/* When nonzero, report use of deprecated classes, methods, or fields. */
+int flag_deprecated = 1;
+
/* When nonzero, always check for a non gcj generated classes archive. */
int flag_force_classes_archive_check;
@@ -224,7 +227,8 @@
{
{ "redundant-modifiers", &flag_redundant, 1 },
{ "extraneous-semicolon", &flag_extraneous_semicolon, 1 },
- { "out-of-date", &flag_newer, 1 }
+ { "out-of-date", &flag_newer, 1 },
+ { "deprecated", &flag_deprecated, 1 }
};
JCF *current_jcf;
Index: gcc/java/lex.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/lex.c,v
retrieving revision 1.97.2.1
diff -u -r1.97.2.1 lex.c
--- gcc/java/lex.c 28 Jan 2003 18:48:16 -0000 1.97.2.1
+++ gcc/java/lex.c 23 Feb 2003 04:54:59 -0000
@@ -1,5 +1,6 @@
/* Language lexer for the GNU compiler for the Java(TM) language.
- Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
+ Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003
+ Free Software Foundation, Inc.
Contributed by Alexandre Petit-Bianco (apbianco at cygnus dot com)
This file is part of GNU CC.
@@ -50,7 +51,8 @@
static int java_parse_escape_sequence PARAMS ((void));
static int java_start_char_p PARAMS ((unicode_t));
static int java_part_char_p PARAMS ((unicode_t));
-static int java_parse_doc_section PARAMS ((int));
+static int java_space_char_p PARAMS ((unicode_t));
+static void java_parse_doc_section PARAMS ((int));
static void java_parse_end_comment PARAMS ((int));
static int java_get_unicode PARAMS ((void));
static int java_read_unicode PARAMS ((java_lexer *, int *));
@@ -684,58 +686,97 @@
}
}
-/* Parse the documentation section. Keywords must be at the beginning
+/* Parse the documentation section. Keywords must be at the beginning
of a documentation comment line (ignoring white space and any `*'
- character). Parsed keyword(s): @DEPRECATED. */
+ character). Parsed keyword(s): ` at deprecated'. */
-static int
+static void
java_parse_doc_section (c)
int c;
{
- int valid_tag = 0, seen_star = 0;
+ int last_was_star;
- while (JAVA_WHITE_SPACE_P (c) || (c == '*') || c == '\n')
- {
- switch (c)
+ /* We reset this here, because only the most recent doc comment
+ applies to the following declaration. */
+ ctxp->deprecated = 0;
+
+ /* We loop over all the lines of the comment. We'll eventually exit
+ if we hit EOF prematurely, or when we see the comment
+ terminator. */
+ while (1)
+ {
+ /* These first steps need only be done if we're still looking
+ for the deprecated tag. If we've already seen it, we might
+ as well skip looking for it again. */
+ if (! ctxp->deprecated)
{
- case '*':
- seen_star = 1;
- break;
- case '\n': /* ULT */
- valid_tag = 1;
- default:
- seen_star = 0;
- }
- c = java_get_unicode();
- }
+ /* Skip whitespace and '*'s. We must also check for the end
+ of the comment here. */
+ while (JAVA_WHITE_SPACE_P (c) || c == '*')
+ {
+ last_was_star = (c == '*');
+ c = java_get_unicode ();
+ if (last_was_star && c == '/')
+ {
+ /* We just saw the comment terminator. */
+ return;
+ }
+ }
- if (c == UEOF)
- java_lex_error ("Comment not terminated at end of input", 0);
+ if (c == UEOF)
+ goto eof;
- if (seen_star && (c == '/'))
- return 1; /* Goto step1 in caller. */
+ if (c == '@')
+ {
+ const char *deprecated = "@deprecated";
+ int i;
- /* We're parsing ` at deprecated'. */
- if (valid_tag && (c == '@'))
- {
- char tag [11];
- int tag_index = 0;
+ for (i = 0; deprecated[i]; ++i)
+ {
+ if (c != deprecated[i])
+ break;
+ /* We write the code in this way, with the
+ update at the end, so that after the loop
+ we're left with the next character in C. */
+ c = java_get_unicode ();
+ }
+
+ if (c == UEOF)
+ goto eof;
+
+ /* @deprecated must be followed by a space or newline.
+ We also allow a '*' in case it appears just before
+ the end of a comment. In this position only we also
+ must allow any Unicode space character. */
+ if (c == ' ' || c == '\n' || c == '*' || java_space_char_p (c))
+ {
+ if (! deprecated[i])
+ ctxp->deprecated = 1;
+ }
+ }
+ }
- while (tag_index < 10 && c != UEOF && c != ' ' && c != '\n')
+ /* We've examined the relevant content from this line. Now we
+ skip the remaining characters and start over with the next
+ line. We also check for end of comment here. */
+ while (c != '\n' && c != UEOF)
{
+ last_was_star = (c == '*');
c = java_get_unicode ();
- tag [tag_index++] = c;
+ if (last_was_star && c == '/')
+ return;
}
if (c == UEOF)
- java_lex_error ("Comment not terminated at end of input", 0);
- tag [tag_index] = '\0';
-
- if (!strcmp (tag, "deprecated"))
- ctxp->deprecated = 1;
+ goto eof;
+ /* We have to advance past the \n. */
+ c = java_get_unicode ();
+ if (c == UEOF)
+ goto eof;
}
- java_unget_unicode ();
- return 0;
+
+ eof:
+ java_lex_error ("Comment not terminated at end of input", 0);
}
/* Return true if C is a valid start character for a Java identifier.
@@ -750,7 +791,7 @@
unsigned long val = (unsigned long) page;
int flags;
- if ((val & ~ (LETTER_PART | LETTER_START)) != 0)
+ if ((val & ~ LETTER_MASK) != 0)
flags = page[c & 255];
else
flags = val;
@@ -770,7 +811,7 @@
unsigned long val = (unsigned long) page;
int flags;
- if ((val & ~ (LETTER_PART | LETTER_START)) != 0)
+ if ((val & ~ LETTER_MASK) != 0)
flags = page[c & 255];
else
flags = val;
@@ -778,6 +819,24 @@
return flags & LETTER_PART;
}
+/* Return true if C is whitespace. */
+static int
+java_space_char_p (c)
+ unicode_t c;
+{
+ unsigned int hi = c / 256;
+ const char *const page = type_table[hi];
+ unsigned long val = (unsigned long) page;
+ int flags;
+
+ if ((val & ~ LETTER_MASK) != 0)
+ flags = page[c & 255];
+ else
+ flags = val;
+
+ return flags & LETTER_SPACE;
+}
+
static int
java_parse_escape_sequence ()
{
@@ -962,13 +1021,19 @@
case '*':
if ((c = java_get_unicode ()) == '*')
{
- if ((c = java_get_unicode ()) == '/')
- goto step1; /* Empty documentation comment. */
- else if (java_parse_doc_section (c))
- goto step1;
+ c = java_get_unicode ();
+ if (c == '/')
+ {
+ /* Empty documentation comment. We have to reset
+ the deprecation marker as only the most recent
+ doc comment applies. */
+ ctxp->deprecated = 0;
+ }
+ else
+ java_parse_doc_section (c);
}
-
- java_parse_end_comment ((c = java_get_unicode ()));
+ else
+ java_parse_end_comment ((c = java_get_unicode ()));
goto step1;
break;
default:
Index: gcc/java/parse.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/parse.h,v
retrieving revision 1.85
diff -u -r1.85 parse.h
--- gcc/java/parse.h 4 Aug 2002 22:45:31 -0000 1.85
+++ gcc/java/parse.h 23 Feb 2003 04:54:59 -0000
@@ -1,5 +1,6 @@
/* Language parser definitions for the GNU compiler for the Java(TM) language.
- Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
+ Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003
+ Free Software Foundation, Inc.
Contributed by Alexandre Petit-Bianco (apbianco at cygnus dot com)
This file is part of GNU CC.
@@ -701,6 +702,14 @@
java_check_abstract_methods ((CLASS)); \
else \
java_check_regular_methods ((CLASS)); \
+ }
+
+#define CLEAR_DEPRECATED ctxp->deprecated = 0
+
+#define CHECK_DEPRECATED_NO_RESET(DECL) \
+ { \
+ if (ctxp->deprecated) \
+ DECL_DEPRECATED (DECL) = 1; \
}
/* Using and reseting the @deprecated tag flag */
Index: gcc/java/parse.y
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/parse.y,v
retrieving revision 1.405.2.6
diff -u -r1.405.2.6 parse.y
--- gcc/java/parse.y 3 Feb 2003 17:48:42 -0000 1.405.2.6
+++ gcc/java/parse.y 23 Feb 2003 04:55:04 -0000
@@ -4363,7 +4363,7 @@
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
@@ -4421,6 +4421,8 @@
DECL_INITIAL (field_decl) = TREE_OPERAND (init, 1);
}
}
+
+ CLEAR_DEPRECATED;
lineno = saved_lineno;
}
@@ -5562,6 +5564,10 @@
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)
@@ -6772,7 +6778,11 @@
/* 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
@@ -9335,6 +9345,8 @@
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. */
@@ -10142,22 +10154,40 @@
check_deprecation (wfl, decl)
tree wfl, 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",
@@ -10532,11 +10562,10 @@
}
/* 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 */
@@ -13636,7 +13665,7 @@
}
break;
- /* 15.19.1 Type Comparison Operator instaceof */
+ /* 15.19.1 Type Comparison Operator instanceof */
case INSTANCEOF_EXPR:
TREE_TYPE (node) = boolean_type_node;
@@ -14403,10 +14432,14 @@
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. */
Index: libjava/ChangeLog
from Tom Tromey <tromey at redhat dot com>
* Makefile.in: Rebuilt.
* Makefile.am (JC1FLAGS): Added -Wno-deprecated.
Index: libjava/Makefile.am
===================================================================
RCS file: /cvs/gcc/gcc/libjava/Makefile.am,v
retrieving revision 1.264.2.10
diff -u -r1.264.2.10 Makefile.am
--- libjava/Makefile.am 12 Feb 2003 20:00:03 -0000 1.264.2.10
+++ libjava/Makefile.am 23 Feb 2003 04:55:09 -0000
@@ -96,7 +96,7 @@
endif
JCFLAGS = -g
-JC1FLAGS = @LIBGCJ_JAVAFLAGS@ $(GCJFLAGS)
+JC1FLAGS = @LIBGCJ_JAVAFLAGS@ -Wno-deprecated $(GCJFLAGS)
LIBFFIINCS = @LIBFFIINCS@
Index: libjava/testsuite/ChangeLog
from Tom Tromey <tromey at redhat dot com>
* libjava.jacks/jacks.xfail: Most 4.7.10 tests pass now.
Index: libjava/testsuite/libjava.jacks/jacks.xfail
===================================================================
RCS file: /cvs/gcc/gcc/libjava/testsuite/libjava.jacks/jacks.xfail,v
retrieving revision 1.1.12.3
diff -u -r1.1.12.3 jacks.xfail
--- libjava/testsuite/libjava.jacks/jacks.xfail 28 Jan 2003 18:48:51 -0000 1.1.12.3
+++ libjava/testsuite/libjava.jacks/jacks.xfail 23 Feb 2003 04:55:12 -0000
@@ -698,45 +698,16 @@
4.5.4-static-5
4.5.4-parameter-2
4.5.4-parameter-3
-4.7.10-jvms-class-1
-4.7.10-jvms-class-2
-4.7.10-jvms-class-3
-4.7.10-jvms-class-4
-4.7.10-jvms-class-5
-4.7.10-jvms-class-10
-4.7.10-jvms-class-11
-4.7.10-jvms-class-12
-4.7.10-jvms-class-13
-4.7.10-jvms-class-14
-4.7.10-jvms-class-17
+4.7.10-jvms-class-6
+4.7.10-jvms-class-7
+4.7.10-jvms-class-8
4.7.10-jvms-class-18
-4.7.10-jvms-class-19
-4.7.10-jvms-method-1
-4.7.10-jvms-method-2
-4.7.10-jvms-method-3
-4.7.10-jvms-method-4
-4.7.10-jvms-method-5
-4.7.10-jvms-method-10
-4.7.10-jvms-constructor-1
-4.7.10-jvms-constructor-2
-4.7.10-jvms-constructor-3
-4.7.10-jvms-constructor-4
-4.7.10-jvms-constructor-5
-4.7.10-jvms-constructor-10
-4.7.10-jvms-constructor-11
-4.7.10-jvms-constructor-12
-4.7.10-jvms-field-1
-4.7.10-jvms-field-2
-4.7.10-jvms-field-3
-4.7.10-jvms-field-4
-4.7.10-jvms-field-5
-4.7.10-jvms-field-10
-4.7.10-jvms-field-11
-4.7.10-jvms-lex-6
-4.7.10-jvms-lex-7
-4.7.10-jvms-lex-8
-4.7.10-jvms-lex-9
-4.7.10-jvms-lex-10
+4.7.10-jvms-method-6
+4.7.10-jvms-method-8
+4.7.10-jvms-constructor-6
+4.7.10-jvms-constructor-8
+4.7.10-jvms-field-6
+4.7.10-jvms-field-8
non-jls-argument-expansion-11
non-jls-argument-expansion-12
non-jls-argument-expansion-13