re PR java/1333 (private field access modifier not implemented correctly)
2003-09-27 Alexandre Petit-Bianco <apbianco@redhat.com> Bryce McKinlay <bryce@mckinlay.net.nz> PR java/1333: * parse.y (not_accessible_field_error): New function. (resolve_expression_name): Check field access permissions. (resolve_qualified_expression_name): Use not_accessible_field_error. (resolve_qualified_expression_name): Likewise. Co-Authored-By: Bryce McKinlay <bryce@mckinlay.net.nz> From-SVN: r71862
This commit is contained in:
parent
e8226879d0
commit
cd11bdcc47
2 changed files with 31 additions and 21 deletions
|
@ -1,3 +1,13 @@
|
|||
2003-09-27 Alexandre Petit-Bianco <apbianco@redhat.com>
|
||||
Bryce McKinlay <bryce@mckinlay.net.nz>
|
||||
|
||||
PR java/1333:
|
||||
* parse.y (not_accessible_field_error): New function.
|
||||
(resolve_expression_name): Check field access permissions.
|
||||
(resolve_qualified_expression_name): Use
|
||||
not_accessible_field_error.
|
||||
(resolve_qualified_expression_name): Likewise.
|
||||
|
||||
2003-09-24 Rainer Orth <ro@TechFak.Uni-Bielefeld.DE>
|
||||
|
||||
* class.c (build_utf8_ref): Test for HAVE_GAS_SHF_MERGE value.
|
||||
|
|
|
@ -250,6 +250,7 @@ static void java_check_regular_methods (tree);
|
|||
static void check_interface_throws_clauses (tree, tree);
|
||||
static void java_check_abstract_methods (tree);
|
||||
static void unreachable_stmt_error (tree);
|
||||
static int not_accessible_field_error (tree, tree);
|
||||
static tree find_expr_with_wfl (tree);
|
||||
static void missing_return_error (tree);
|
||||
static tree build_new_array_init (int, tree);
|
||||
|
@ -3161,6 +3162,18 @@ unreachable_stmt_error (tree node)
|
|||
abort ();
|
||||
}
|
||||
|
||||
static int
|
||||
not_accessible_field_error (tree wfl, tree decl)
|
||||
{
|
||||
parse_error_context
|
||||
(wfl, "Can't access %s field `%s.%s' from `%s'",
|
||||
java_accstring_lookup (get_access_flags_from_decl (decl)),
|
||||
GET_TYPE_NAME (DECL_CONTEXT (decl)),
|
||||
IDENTIFIER_POINTER (DECL_NAME (decl)),
|
||||
IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (current_class))));
|
||||
return 1;
|
||||
}
|
||||
|
||||
int
|
||||
java_report_errors (void)
|
||||
{
|
||||
|
@ -9353,6 +9366,12 @@ resolve_expression_name (tree id, tree *orig)
|
|||
/* We may be asked to save the real field access node */
|
||||
if (orig)
|
||||
*orig = access;
|
||||
/* Last check: can we access the field? */
|
||||
if (not_accessible_p (current_class, decl, NULL_TREE, 0))
|
||||
{
|
||||
not_accessible_field_error (id, decl);
|
||||
return error_mark_node;
|
||||
}
|
||||
/* And we return what we got */
|
||||
return access;
|
||||
}
|
||||
|
@ -9832,15 +9851,7 @@ resolve_qualified_expression_name (tree wfl, tree *found_decl,
|
|||
}
|
||||
|
||||
if (not_accessible_p (TREE_TYPE (decl), decl, type, 0))
|
||||
{
|
||||
parse_error_context
|
||||
(qual_wfl, "Can't access %s field `%s.%s' from `%s'",
|
||||
java_accstring_lookup (get_access_flags_from_decl (decl)),
|
||||
GET_TYPE_NAME (type),
|
||||
IDENTIFIER_POINTER (DECL_NAME (decl)),
|
||||
IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (current_class))));
|
||||
return 1;
|
||||
}
|
||||
return not_accessible_field_error (qual_wfl, decl);
|
||||
check_deprecation (qual_wfl, decl);
|
||||
|
||||
type = TREE_TYPE (decl);
|
||||
|
@ -9961,18 +9972,7 @@ resolve_qualified_expression_name (tree wfl, tree *found_decl,
|
|||
/* Check on accessibility here */
|
||||
if (not_accessible_p (current_class, field_decl,
|
||||
DECL_CONTEXT (field_decl), from_super))
|
||||
{
|
||||
parse_error_context
|
||||
(qual_wfl,
|
||||
"Can't access %s field `%s.%s' from `%s'",
|
||||
java_accstring_lookup
|
||||
(get_access_flags_from_decl (field_decl)),
|
||||
GET_TYPE_NAME (type),
|
||||
IDENTIFIER_POINTER (DECL_NAME (field_decl)),
|
||||
IDENTIFIER_POINTER
|
||||
(DECL_NAME (TYPE_NAME (current_class))));
|
||||
return 1;
|
||||
}
|
||||
return not_accessible_field_error (qual_wfl,field_decl);
|
||||
check_deprecation (qual_wfl, field_decl);
|
||||
|
||||
/* There are things to check when fields are accessed
|
||||
|
|
Loading…
Add table
Reference in a new issue