mirror of
git://gcc.gnu.org/git/gcc.git
synced 2024-12-30 11:05:09 +08:00
[multiple changes]
2000-06-23 Alexandre Petit-Bianco <apbianco@cygnus.com> * class.c (set_super_info): Handle ACC_PRIVATE for (inner) classes. * java-tree.h (TYPE_PRIVATE_INNER_CLASS): New macro. (struct lang_type): New field `pic.' (CLASS_PRIVATE): New macro. * parse.y (check_inner_class_access): New function. (jdep_resolve_class): Call it. 2000-06-09 Bryce McKinlay <bryce@albatross.co.nz> * parse.y (register_fields): Permit static fields in inner classes if they are final. Fix for PR gcj/255. (These patches are fixes to the PR #224 and #255: http://sourceware.cygnus.com/ml/java-prs/2000-q2/msg00158.html http://sourceware.cygnus.com/ml/java-prs/2000-q2/msg00287.html) From-SVN: r34725
This commit is contained in:
parent
047142d32e
commit
cf1748bfce
@ -18,6 +18,16 @@
|
||||
* parse.y (check_abstract_method_definitions): Also check if
|
||||
`other_method' is abstract.
|
||||
|
||||
2000-06-23 Alexandre Petit-Bianco <apbianco@cygnus.com>
|
||||
|
||||
* class.c (set_super_info): Handle ACC_PRIVATE for (inner)
|
||||
classes.
|
||||
* java-tree.h (TYPE_PRIVATE_INNER_CLASS): New macro.
|
||||
(struct lang_type): New field `pic.'
|
||||
(CLASS_PRIVATE): New macro.
|
||||
* parse.y (check_inner_class_access): New function.
|
||||
(jdep_resolve_class): Call it.
|
||||
|
||||
2000-06-23 Tom Tromey <tromey@cygnus.com>
|
||||
|
||||
* parse.y (patch_incomplete_class_ref): Initialize the returned
|
||||
@ -84,6 +94,11 @@
|
||||
|
||||
* lang.c (lang_get_alias_set): Mark parameter with ATTRIBUTE_UNUSED.
|
||||
|
||||
2000-06-09 Bryce McKinlay <bryce@albatross.co.nz>
|
||||
|
||||
* parse.y (register_fields): Permit static fields in inner classes
|
||||
if they are final. Fix for PR gcj/255.
|
||||
|
||||
2000-06-06 Alexandre Petit-Bianco <apbianco@cygnus.com>
|
||||
|
||||
* parse.h (REGISTER_IMPORT): Use `chainon' to link new entries.
|
||||
|
@ -400,6 +400,7 @@ set_super_info (access_flags, this_class, super_class, interfaces_count)
|
||||
if (access_flags & ACC_INTERFACE) CLASS_INTERFACE (class_decl) = 1;
|
||||
if (access_flags & ACC_ABSTRACT) CLASS_ABSTRACT (class_decl) = 1;
|
||||
if (access_flags & ACC_STATIC) CLASS_STATIC (class_decl) = 1;
|
||||
if (access_flags & ACC_PRIVATE) CLASS_PRIVATE (class_decl) = 1;
|
||||
}
|
||||
|
||||
/* Return length of inheritance chain of CLAS, where java.lang.Object is 0,
|
||||
|
@ -575,6 +575,7 @@ struct lang_decl_var
|
||||
/* The decl of the synthetic method `class$' used to handle `.class'
|
||||
for non primitive types when compiling to bytecode. */
|
||||
#define TYPE_DOT_CLASS(T) (TYPE_LANG_SPECIFIC(T)->dot_class)
|
||||
#define TYPE_PRIVATE_INNER_CLASS(T) (TYPE_LANG_SPECIFIC(T)->pic)
|
||||
|
||||
struct lang_type
|
||||
{
|
||||
@ -589,6 +590,7 @@ struct lang_type
|
||||
needs to be invoked and generated when
|
||||
compiling to bytecode to implement
|
||||
<non_primitive_type>.class */
|
||||
unsigned pic:1; /* Private Inner Class. */
|
||||
};
|
||||
|
||||
#ifdef JAVA_USE_HANDLES
|
||||
@ -837,6 +839,7 @@ struct rtx_def * java_lang_expand_expr PARAMS ((tree, rtx, enum machine_mode,
|
||||
#define CLASS_ABSTRACT(DECL) DECL_LANG_FLAG_5 (DECL)
|
||||
#define CLASS_SUPER(DECL) DECL_LANG_FLAG_6 (DECL)
|
||||
#define CLASS_STATIC(DECL) DECL_LANG_FLAG_7 (DECL)
|
||||
#define CLASS_PRIVATE(DECL) (TYPE_PRIVATE_INNER_CLASS (TREE_TYPE (DECL)))
|
||||
|
||||
/* @deprecated marker flag on methods, fields and classes */
|
||||
|
||||
|
889
gcc/java/parse.c
889
gcc/java/parse.c
File diff suppressed because it is too large
Load Diff
@ -100,6 +100,7 @@ static int process_imports PARAMS ((void));
|
||||
static void read_import_dir PARAMS ((tree));
|
||||
static int find_in_imports_on_demand PARAMS ((tree));
|
||||
static void find_in_imports PARAMS ((tree));
|
||||
static void check_inner_class_access PARAMS ((tree, tree, tree));
|
||||
static int check_pkg_class_access PARAMS ((tree, tree));
|
||||
static void register_package PARAMS ((tree));
|
||||
static tree resolve_package PARAMS ((tree, tree *));
|
||||
@ -4117,11 +4118,11 @@ register_fields (flags, type, variable_list)
|
||||
tree init = TREE_VALUE (current);
|
||||
tree current_name = EXPR_WFL_NODE (cl);
|
||||
|
||||
/* Can't declare static fields in inner classes */
|
||||
/* Can't declare non-final static fields in inner classes */
|
||||
if ((flags & ACC_STATIC) && !TOPLEVEL_CLASS_TYPE_P (class_type)
|
||||
&& !CLASS_INTERFACE (TYPE_NAME (class_type)))
|
||||
&& !(flags & ACC_FINAL))
|
||||
parse_error_context
|
||||
(cl, "Field `%s' can't be static in innerclass `%s'. Only members of interfaces and top-level classes can be static",
|
||||
(cl, "Field `%s' can't be static in inner class `%s' unless it is final",
|
||||
IDENTIFIER_POINTER (EXPR_WFL_NODE (cl)),
|
||||
lang_printable_name (class_type, 0));
|
||||
|
||||
@ -5207,6 +5208,7 @@ jdep_resolve_class (dep)
|
||||
if (!decl)
|
||||
complete_class_report_errors (dep);
|
||||
|
||||
check_inner_class_access (decl, JDEP_ENCLOSING (dep), JDEP_WFL (dep));
|
||||
return decl;
|
||||
}
|
||||
|
||||
@ -6780,6 +6782,27 @@ lookup_package_type (name, from)
|
||||
return get_identifier (subname);
|
||||
}
|
||||
|
||||
static void
|
||||
check_inner_class_access (decl, enclosing_type, cl)
|
||||
tree decl, enclosing_type, cl;
|
||||
{
|
||||
/* We don't issue an error message when CL is null. CL can be null
|
||||
as a result of processing a JDEP crafted by
|
||||
source_start_java_method for the purpose of patching its parm
|
||||
decl. But the error would have been already trapped when fixing
|
||||
the method's signature. */
|
||||
if (!(cl && PURE_INNER_CLASS_DECL_P (decl) && CLASS_PRIVATE (decl))
|
||||
|| (PURE_INNER_CLASS_DECL_P (enclosing_type)
|
||||
&& common_enclosing_context_p (TREE_TYPE (enclosing_type),
|
||||
TREE_TYPE (decl)))
|
||||
|| enclosing_context_p (TREE_TYPE (enclosing_type), TREE_TYPE (decl)))
|
||||
return;
|
||||
|
||||
parse_error_context (cl, "Can't access nested %s %s. Only public classes and interfaces in other packages can be accessed",
|
||||
(CLASS_INTERFACE (decl) ? "interface" : "class"),
|
||||
lang_printable_name (decl, 0));
|
||||
}
|
||||
|
||||
/* Check that CLASS_NAME refers to a PUBLIC class. Return 0 if no
|
||||
access violations were found, 1 otherwise. */
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user