Commit 7cef5027 by Andrew Pinski Committed by Andrew Pinski

parse.y (check_pkg_class_access): Add new argument and use it when cl is NULL to…

parse.y (check_pkg_class_access): Add new argument and use it when cl is NULL to call lookup_cl on it.

2004-05-10  Andrew Pinski  <pinskia@physics.uc.edu>

        * parse.y (check_pkg_class_access): Add new argument
        and use it when cl is NULL to call lookup_cl on it.
        (parser_check_super_interface): Do not call lookup_cl.
        Pass this_decl to check_pkg_class_access and NULL
        instead of lookup_cl.
        (parser_check_super): Update for change in
        check_pkg_class_access.
        (do_resolve_class): Likewise.
        (process_imports): Likewise.
        (find_in_imports_on_demand): Likewise.
        (resolve_qualified_expression_name): Likewise.

From-SVN: r81668
parent 731d47a6
2004-05-10 Andrew Pinski <pinskia@physics.uc.edu>
* parse.y (check_pkg_class_access): Add new argument
and use it when cl is NULL to call lookup_cl on it.
(parser_check_super_interface): Do not call lookup_cl.
Pass this_decl to check_pkg_class_access and NULL
instead of lookup_cl.
(parser_check_super): Update for change in
check_pkg_class_access.
(do_resolve_class): Likewise.
(process_imports): Likewise.
(find_in_imports_on_demand): Likewise.
(resolve_qualified_expression_name): Likewise.
2004-05-06 Ranjit Mathew <rmathew@hotmail.com> 2004-05-06 Ranjit Mathew <rmathew@hotmail.com>
Fixes PR java/9685, PR java/15073 Fixes PR java/9685, PR java/15073
......
...@@ -107,7 +107,7 @@ static void read_import_dir (tree); ...@@ -107,7 +107,7 @@ static void read_import_dir (tree);
static int find_in_imports_on_demand (tree, tree); static int find_in_imports_on_demand (tree, tree);
static void find_in_imports (tree, tree); static void find_in_imports (tree, tree);
static void check_inner_class_access (tree, tree, tree); static void check_inner_class_access (tree, tree, tree);
static int check_pkg_class_access (tree, tree, bool); static int check_pkg_class_access (tree, tree, bool, tree);
static void register_package (tree); static void register_package (tree);
static tree resolve_package (tree, tree *, tree *); static tree resolve_package (tree, tree *, tree *);
static tree resolve_class (tree, tree, tree, tree); static tree resolve_class (tree, tree, tree, tree);
...@@ -5079,7 +5079,7 @@ parser_check_super_interface (tree super_decl, tree this_decl, tree this_wfl) ...@@ -5079,7 +5079,7 @@ parser_check_super_interface (tree super_decl, tree this_decl, tree this_wfl)
access rules (6.6.1). */ access rules (6.6.1). */
if (! INNER_CLASS_P (super_type) if (! INNER_CLASS_P (super_type)
&& check_pkg_class_access (DECL_NAME (super_decl), && check_pkg_class_access (DECL_NAME (super_decl),
lookup_cl (this_decl), true)) NULL_TREE, true, this_decl))
return 1; return 1;
SOURCE_FRONTEND_DEBUG (("Completing interface %s with %s", SOURCE_FRONTEND_DEBUG (("Completing interface %s with %s",
...@@ -5117,7 +5117,7 @@ parser_check_super (tree super_decl, tree this_decl, tree wfl) ...@@ -5117,7 +5117,7 @@ parser_check_super (tree super_decl, tree this_decl, tree wfl)
/* Check top-level class scope. Inner classes are subject to member access /* Check top-level class scope. Inner classes are subject to member access
rules (6.6.1). */ rules (6.6.1). */
if (! INNER_CLASS_P (super_type) if (! INNER_CLASS_P (super_type)
&& (check_pkg_class_access (DECL_NAME (super_decl), wfl, true))) && (check_pkg_class_access (DECL_NAME (super_decl), wfl, true, NULL_TREE)))
return 1; return 1;
SOURCE_FRONTEND_DEBUG (("Completing class %s with %s", SOURCE_FRONTEND_DEBUG (("Completing class %s with %s",
...@@ -5857,7 +5857,7 @@ do_resolve_class (tree enclosing, tree class_type, tree decl, tree cl) ...@@ -5857,7 +5857,7 @@ do_resolve_class (tree enclosing, tree class_type, tree decl, tree cl)
by the caller. */ by the caller. */
if (cl) if (cl)
{ {
if (check_pkg_class_access (TYPE_NAME (class_type), cl, true)) if (check_pkg_class_access (TYPE_NAME (class_type), cl, true, NULL_TREE))
return NULL_TREE; return NULL_TREE;
} }
...@@ -6817,7 +6817,7 @@ process_imports (void) ...@@ -6817,7 +6817,7 @@ process_imports (void)
QUALIFIED_P (to_be_found) = 1; QUALIFIED_P (to_be_found) = 1;
load_class (to_be_found, 0); load_class (to_be_found, 0);
error_found = error_found =
check_pkg_class_access (to_be_found, TREE_PURPOSE (import), true); check_pkg_class_access (to_be_found, TREE_PURPOSE (import), true, NULL_TREE);
/* We found it, we can bail out */ /* We found it, we can bail out */
if (IDENTIFIER_CLASS_VALUE (to_be_found)) if (IDENTIFIER_CLASS_VALUE (to_be_found))
...@@ -7061,7 +7061,7 @@ find_in_imports_on_demand (tree enclosing_type, tree class_type) ...@@ -7061,7 +7061,7 @@ find_in_imports_on_demand (tree enclosing_type, tree class_type)
} }
if (decl && ! INNER_CLASS_P (TREE_TYPE (decl))) if (decl && ! INNER_CLASS_P (TREE_TYPE (decl)))
access_check = check_pkg_class_access (node, TREE_PURPOSE (import), access_check = check_pkg_class_access (node, TREE_PURPOSE (import),
false); false, NULL_TREE);
else else
/* 6.6.1: Inner classes are subject to member access rules. */ /* 6.6.1: Inner classes are subject to member access rules. */
access_check = 0; access_check = 0;
...@@ -7247,10 +7247,11 @@ check_inner_class_access (tree decl, tree enclosing_decl, tree cl) ...@@ -7247,10 +7247,11 @@ check_inner_class_access (tree decl, tree enclosing_decl, tree cl)
/* Accessibility check for top-level classes. If CLASS_NAME is in a /* Accessibility check for top-level classes. If CLASS_NAME is in a
foreign package, it must be PUBLIC. Return 0 if no access foreign package, it must be PUBLIC. Return 0 if no access
violations were found, 1 otherwise. If VERBOSE is true and an error violations were found, 1 otherwise. If VERBOSE is true and an error
was found, it is reported and accounted for. */ was found, it is reported and accounted for. If CL is NULL then
look it up with THIS_DECL. */
static int static int
check_pkg_class_access (tree class_name, tree cl, bool verbose) check_pkg_class_access (tree class_name, tree cl, bool verbose, tree this_decl)
{ {
tree type; tree type;
...@@ -7275,7 +7276,8 @@ check_pkg_class_access (tree class_name, tree cl, bool verbose) ...@@ -7275,7 +7276,8 @@ check_pkg_class_access (tree class_name, tree cl, bool verbose)
if (verbose) if (verbose)
parse_error_context parse_error_context
(cl, "Can't access %s `%s'. Only public classes and interfaces in other packages can be accessed", (cl == NULL ? lookup_cl (this_decl): cl,
"Can't access %s `%s'. Only public classes and interfaces in other packages can be accessed",
(CLASS_INTERFACE (TYPE_NAME (type)) ? "interface" : "class"), (CLASS_INTERFACE (TYPE_NAME (type)) ? "interface" : "class"),
IDENTIFIER_POINTER (class_name)); IDENTIFIER_POINTER (class_name));
return 1; return 1;
...@@ -9836,7 +9838,7 @@ resolve_qualified_expression_name (tree wfl, tree *found_decl, ...@@ -9836,7 +9838,7 @@ resolve_qualified_expression_name (tree wfl, tree *found_decl,
tree list; tree list;
*where_found = decl; *where_found = decl;
check_pkg_class_access (DECL_NAME (decl), qual_wfl, true); check_pkg_class_access (DECL_NAME (decl), qual_wfl, true, NULL);
/* We want to be absolutely sure that the class is laid /* We want to be absolutely sure that the class is laid
out. We're going to search something inside it. */ out. We're going to search something inside it. */
...@@ -9888,7 +9890,7 @@ resolve_qualified_expression_name (tree wfl, tree *found_decl, ...@@ -9888,7 +9890,7 @@ resolve_qualified_expression_name (tree wfl, tree *found_decl,
return 1; return 1;
} }
check_pkg_class_access (DECL_NAME (decl), qual_wfl, true); check_pkg_class_access (DECL_NAME (decl), qual_wfl, true, NULL);
check_deprecation (qual_wfl, decl); check_deprecation (qual_wfl, decl);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment