aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexandre Petit-Bianco <apbianco@cygnus.com>1999-02-19 05:27:35 -0800
committerPer Bothner <bothner@gcc.gnu.org>1999-02-19 05:27:35 -0800
commite28cd97b00fe7bddae105d4d92e26ba254a68d9a (patch)
treee750e6c4415cc885b119c08e9982ff4bc3238314
parent19378cf80343bc455c6d3ef513365aaf58884222 (diff)
downloadgcc-e28cd97b00fe7bddae105d4d92e26ba254a68d9a.zip
gcc-e28cd97b00fe7bddae105d4d92e26ba254a68d9a.tar.gz
gcc-e28cd97b00fe7bddae105d4d92e26ba254a68d9a.tar.bz2
parse.y (check_pkg_class_access): Allow private class access within the same package.
* parse.y (check_pkg_class_access): Allow private class access within the same package. (strip_out_static_field_access_decl): New function. (patch_unaryop): Call strip_out_static_field_access_decl on ++/-- operator argument before testing its nature. From-SVN: r25317
-rw-r--r--gcc/java/parse.y42
1 files changed, 38 insertions, 4 deletions
diff --git a/gcc/java/parse.y b/gcc/java/parse.y
index 0225791..8079bde 100644
--- a/gcc/java/parse.y
+++ b/gcc/java/parse.y
@@ -239,6 +239,7 @@ static int array_constructor_check_entry PROTO ((tree, tree));
static char *purify_type_name PROTO ((char *));
static tree patch_initialized_static_field PROTO ((tree));
static tree fold_constant_for_init PROTO ((tree, tree));
+static tree strip_out_static_field_access_decl PROTO ((tree));
/* Number of error found so far. */
int java_error_count;
@@ -5206,6 +5207,13 @@ check_pkg_class_access (class_name, cl)
if (!CLASS_PUBLIC (TYPE_NAME (type)))
{
+ /* Access to a private class within the same package is
+ allowed. */
+ tree l, r;
+ breakdown_qualified (&l, &r, class_name);
+ if (l == ctxp->package)
+ return 0;
+
parse_error_context
(cl, "Can't access %s `%s'. Only public classes and interfaces in "
"other packages can be accessed",
@@ -6158,6 +6166,30 @@ resolve_field_access (qual_wfl, field_decl, field_type)
return field_ref;
}
+/* If NODE is an access to f static field, strip out the class
+ initialization part and return the field decl, otherwise, return
+ NODE. */
+
+static tree
+strip_out_static_field_access_decl (node)
+ tree node;
+{
+ if (TREE_CODE (node) == COMPOUND_EXPR)
+ {
+ tree op1 = TREE_OPERAND (node, 1);
+ if (TREE_CODE (op1) == COMPOUND_EXPR)
+ {
+ tree call = TREE_OPERAND (op1, 0);
+ if (TREE_CODE (call) == CALL_EXPR
+ && TREE_CODE (TREE_OPERAND (call, 0)) == ADDR_EXPR
+ && TREE_OPERAND (TREE_OPERAND (call, 0), 0)
+ == soft_initclass_node)
+ return TREE_OPERAND (op1, 1);
+ }
+ }
+ return node;
+}
+
/* 6.5.5.2: Qualified Expression Names */
static int
@@ -9493,7 +9525,7 @@ patch_unaryop (node, wfl_op)
{
tree op = TREE_OPERAND (node, 0);
tree op_type = TREE_TYPE (op);
- tree prom_type, value;
+ tree prom_type, value, decl;
int code = TREE_CODE (node);
int error_found = 0;
@@ -9509,9 +9541,11 @@ patch_unaryop (node, wfl_op)
case PREINCREMENT_EXPR:
/* 15.14.2 Prefix Decrement Operator -- */
case PREDECREMENT_EXPR:
- if (!JDECL_P (op) && !((TREE_CODE (op) == INDIRECT_REF
- || TREE_CODE (op) == COMPONENT_REF)
- && JPRIMITIVE_TYPE_P (TREE_TYPE (op))))
+ decl = strip_out_static_field_access_decl (op);
+ if (!JDECL_P (decl)
+ && !((TREE_CODE (decl) == INDIRECT_REF
+ || TREE_CODE (decl) == COMPONENT_REF)
+ && JPRIMITIVE_TYPE_P (TREE_TYPE (decl))))
{
tree lvalue;
/* Before screaming, check that we're not in fact trying to