aboutsummaryrefslogtreecommitdiff
path: root/gcc/java/jcf-write.c
diff options
context:
space:
mode:
authorBryce McKinlay <mckinlay@redhat.com>2004-07-10 05:38:15 +0000
committerBryce McKinlay <bryce@gcc.gnu.org>2004-07-10 06:38:15 +0100
commitd3ecb597b35d5b8c4176a0b60c10cbfdb40ace8b (patch)
treebcd4a6d234666cbea3ddc05897321cf2a6b159ef /gcc/java/jcf-write.c
parenta7e5372d6a8e2f12b6d9a15f71d5ad0794e6507f (diff)
downloadgcc-d3ecb597b35d5b8c4176a0b60c10cbfdb40ace8b.zip
gcc-d3ecb597b35d5b8c4176a0b60c10cbfdb40ace8b.tar.gz
gcc-d3ecb597b35d5b8c4176a0b60c10cbfdb40ace8b.tar.bz2
re PR java/8618 (call to private constructor allowed for anonymous inner class)
2004-07-09 Bryce McKinlay <mckinlay@redhat.com> PR java/8618 * parse.y (create_anonymous_class): Remove 'location' argument. Use the WFL from TYPE_NAME to get line number for the decl. Fix comment. (craft_constructor): Inherit access flags for implicit constructor from the enclosing class. (create_class): Fix comment typo. (resolve_qualified_expression_name): Pass type of qualifier to not_accessible_p, not the type in which target field was found. (not_accessible_p): Handle inner classes. Expand protected qualifier-subtype check to enclosing instances, but don't apply this check to static members. Allow protected access to inner classes of a subtype. Allow private access within common enclosing context. (build_super_invocation): Get WFL line number info from current class decl. (build_incomplete_class_ref): Update for new create_anonymous_class signature. * parse.h (INNER_ENCLOSING_SCOPE_CHECK): Use common_enclosing_instance_p. * class.c (common_enclosing_context_p): New. Determine if types share a common enclosing context, even across static contexts. (common_enclosing_instance_p): Renamed from common_enclosing_context_p. Determines if types share a common non-static enclosing instance. * java-tree.h (common_enclosing_instance_p): Declare. * jcf-write.c (get_method_access_flags): New. Surpress private flag for inner class constructors. (generate_classfile): Use get_method_access_flags. From-SVN: r84443
Diffstat (limited to 'gcc/java/jcf-write.c')
-rw-r--r--gcc/java/jcf-write.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/gcc/java/jcf-write.c b/gcc/java/jcf-write.c
index c95df1e..e34543c 100644
--- a/gcc/java/jcf-write.c
+++ b/gcc/java/jcf-write.c
@@ -2903,6 +2903,22 @@ get_classfile_modifiers (tree class)
return flags;
}
+/* Get the access flags (modifiers) for a method to be used in the class
+ file. */
+
+static int
+get_method_access_flags (tree decl)
+{
+ int flags = get_access_flags (decl);
+
+ /* Promote "private" inner-class constructors to package-private. */
+ if (DECL_CONSTRUCTOR_P (decl)
+ && INNER_CLASS_DECL_P (TYPE_NAME (DECL_CONTEXT (decl))))
+ flags &= ~(ACC_PRIVATE);
+
+ return flags;
+}
+
/* Generate and return a list of chunks containing the class CLAS
in the .class file representation. The list can be written to a
.class file using write_chunks. Allocate chunks from obstack WORK. */
@@ -3034,7 +3050,7 @@ generate_classfile (tree clas, struct jcf_partial *state)
current_function_decl = part;
ptr = append_chunk (NULL, 8, state);
- i = get_access_flags (part); PUT2 (i);
+ i = get_method_access_flags (part); PUT2 (i);
i = find_utf8_constant (&state->cpool, name); PUT2 (i);
i = find_utf8_constant (&state->cpool, build_java_signature (type));
PUT2 (i);