aboutsummaryrefslogtreecommitdiff
path: root/gcc/java
diff options
context:
space:
mode:
authorBryce McKinlay <mckinlay@redhat.com>2005-09-15 14:13:03 +0000
committerBryce McKinlay <bryce@gcc.gnu.org>2005-09-15 15:13:03 +0100
commitc629e611eb78853f8ccd85173b758cabbdc0e56b (patch)
treeacb467137b30cf006a229fb261743c29c869d147 /gcc/java
parentec05ece4b9e0fdcc6afd9d5d89d859cb95ccb321 (diff)
downloadgcc-c629e611eb78853f8ccd85173b758cabbdc0e56b.zip
gcc-c629e611eb78853f8ccd85173b758cabbdc0e56b.tar.gz
gcc-c629e611eb78853f8ccd85173b758cabbdc0e56b.tar.bz2
re PR java/23891 (Problem folding static fields across packages)
2005-09-14 Bryce McKinlay <mckinlay@redhat.com> PR java/23891 * parse.y (maybe_create_class_interface_decl): Set TYPE_PACKAGE for the newly created type. Set import lists here, not in create_class. (jdep_resolve_class): Set current_class. (do_resolve_class): Use current_class's TYPE_PACKAGE to determine the current package context, not ctxp->package. (cicp_cache): Removed. (class_in_current_package): Simplify implementation using TYPE_PACKAGE. * jcf-parse.c (give_name_to_class): Set TYPE_PACKAGE. * java-tree.h (TYPE_PACKAGE): New macro. (struct lang_type): New member 'package'. From-SVN: r104305
Diffstat (limited to 'gcc/java')
-rw-r--r--gcc/java/ChangeLog14
-rw-r--r--gcc/java/java-tree.h4
-rw-r--r--gcc/java/jcf-parse.c4
-rw-r--r--gcc/java/parse.y49
4 files changed, 36 insertions, 35 deletions
diff --git a/gcc/java/ChangeLog b/gcc/java/ChangeLog
index ed96553..dcdb716 100644
--- a/gcc/java/ChangeLog
+++ b/gcc/java/ChangeLog
@@ -1,3 +1,17 @@
+2005-09-14 Bryce McKinlay <mckinlay@redhat.com>
+
+ PR java/23891
+ * parse.y (maybe_create_class_interface_decl): Set TYPE_PACKAGE for
+ the newly created type. Set import lists here, not in create_class.
+ (jdep_resolve_class): Set current_class.
+ (do_resolve_class): Use current_class's TYPE_PACKAGE to determine
+ the current package context, not ctxp->package.
+ (cicp_cache): Removed.
+ (class_in_current_package): Simplify implementation using TYPE_PACKAGE.
+ * jcf-parse.c (give_name_to_class): Set TYPE_PACKAGE.
+ * java-tree.h (TYPE_PACKAGE): New macro.
+ (struct lang_type): New member 'package'.
+
2005-09-09 Andrew Haley <aph@redhat.com>
PR libgcj/23182
diff --git a/gcc/java/java-tree.h b/gcc/java/java-tree.h
index 8f30878..658da38 100644
--- a/gcc/java/java-tree.h
+++ b/gcc/java/java-tree.h
@@ -1074,6 +1074,7 @@ struct lang_decl GTY(())
#define TYPE_TO_RUNTIME_MAP(T) (TYPE_LANG_SPECIFIC (T)->type_to_runtime_map)
#define TYPE_ASSERTIONS(T) (TYPE_LANG_SPECIFIC (T)->type_assertions)
+#define TYPE_PACKAGE(T) (TYPE_LANG_SPECIFIC (T)->package)
struct lang_type GTY(())
{
@@ -1122,6 +1123,9 @@ struct lang_type GTY(())
/* Table of type assertions to be evaluated
by the runtime when this class is loaded. */
+ tree package; /* IDENTIFIER_NODE for package this class is
+ a member of. */
+
unsigned pic:1; /* Private Inner Class. */
unsigned poic:1; /* Protected Inner Class. */
unsigned strictfp:1; /* `strictfp' class. */
diff --git a/gcc/java/jcf-parse.c b/gcc/java/jcf-parse.c
index 425dc4d..5d22f88 100644
--- a/gcc/java/jcf-parse.c
+++ b/gcc/java/jcf-parse.c
@@ -444,6 +444,7 @@ give_name_to_class (JCF *jcf, int i)
abort ();
else
{
+ tree package_name = NULL_TREE, tmp;
tree this_class;
int j = JPOOL_USHORT1 (jcf, i);
/* verify_constant_pool confirmed that j is a CONSTANT_Utf8. */
@@ -469,6 +470,9 @@ give_name_to_class (JCF *jcf, int i)
jcf->cpool.data[i].t = this_class;
JPOOL_TAG (jcf, i) = CONSTANT_ResolvedClass;
+ split_qualified_name (&package_name, &tmp,
+ DECL_NAME (TYPE_NAME (this_class)));
+ TYPE_PACKAGE (this_class) = package_name;
return this_class;
}
}
diff --git a/gcc/java/parse.y b/gcc/java/parse.y
index 11c2738..4d6a37f 100644
--- a/gcc/java/parse.y
+++ b/gcc/java/parse.y
@@ -3911,6 +3911,14 @@ maybe_create_class_interface_decl (tree decl, tree raw_name,
/* Install a new dependency list element */
create_jdep_list (ctxp);
+ /* We keep the compilation unit imports in the class so that
+ they can be used later to resolve type dependencies that
+ aren't necessary to solve now. */
+ TYPE_IMPORT_LIST (TREE_TYPE (decl)) = ctxp->import_list;
+ TYPE_IMPORT_DEMAND_LIST (TREE_TYPE (decl)) = ctxp->import_demand_list;
+
+ TYPE_PACKAGE (TREE_TYPE (decl)) = ctxp->package;
+
SOURCE_FRONTEND_DEBUG (("Defining class/interface %s",
IDENTIFIER_POINTER (qualified_name)));
return decl;
@@ -4185,12 +4193,6 @@ create_class (int flags, tree id, tree super, tree interfaces)
virtual function table in java.lang.object. */
TYPE_VFIELD (TREE_TYPE (decl)) = TYPE_VFIELD (object_type_node);
- /* We keep the compilation unit imports in the class so that
- they can be used later to resolve type dependencies that
- aren't necessary to solve now. */
- TYPE_IMPORT_LIST (TREE_TYPE (decl)) = ctxp->import_list;
- TYPE_IMPORT_DEMAND_LIST (TREE_TYPE (decl)) = ctxp->import_demand_list;
-
/* Add the private this$<n> field, Replicate final locals still in
scope as private final fields mangled like val$<local_name>.
This does not occur for top level (static) inner classes. */
@@ -5644,6 +5646,9 @@ static tree
jdep_resolve_class (jdep *dep)
{
tree decl;
+
+ /* Set the correct context for class resolution. */
+ current_class = TREE_TYPE (JDEP_ENCLOSING (dep));
if (JDEP_RESOLVED_P (dep))
decl = JDEP_RESOLVED_DECL (dep);
@@ -5947,8 +5952,8 @@ do_resolve_class (tree enclosing, tree import_type, tree class_type, tree decl,
/* 3- Search according to the current package definition */
if (!QUALIFIED_P (TYPE_NAME (class_type)))
{
- if ((new_class_decl = qualify_and_find (class_type, ctxp->package,
- TYPE_NAME (class_type))))
+ if ((new_class_decl = qualify_and_find (class_type,
+ TYPE_PACKAGE (current_class), TYPE_NAME (class_type))))
return new_class_decl;
}
@@ -10446,37 +10451,11 @@ check_deprecation (tree wfl, tree decl)
/* Returns 1 if class was declared in the current package, 0 otherwise */
-static GTY(()) tree cicp_cache;
static int
class_in_current_package (tree class)
{
- int qualified_flag;
- tree left;
-
- if (cicp_cache == class)
- return 1;
-
- qualified_flag = QUALIFIED_P (DECL_NAME (TYPE_NAME (class)));
-
- /* If the current package is empty and the name of CLASS is
- qualified, class isn't in the current package. If there is a
- current package and the name of the CLASS is not qualified, class
- isn't in the current package */
- if ((!ctxp->package && qualified_flag) || (ctxp->package && !qualified_flag))
- return 0;
-
- /* If there is not package and the name of CLASS isn't qualified,
- they belong to the same unnamed package */
- if (!ctxp->package && !qualified_flag)
+ if (TYPE_PACKAGE (current_class) == TYPE_PACKAGE (class))
return 1;
-
- /* Compare the left part of the name of CLASS with the package name */
- split_qualified_name (&left, NULL, DECL_NAME (TYPE_NAME (class)));
- if (ctxp->package == left)
- {
- cicp_cache = class;
- return 1;
- }
return 0;
}