This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
4.0 Patch: Fix PR 23891
- From: Bryce McKinlay <mckinlay at redhat dot com>
- To: java-patches at gcc dot gnu dot org, gcc-patches at gcc dot gnu dot org
- Date: Sat, 01 Oct 2005 02:19:45 -0400
- Subject: 4.0 Patch: Fix PR 23891
This patch applies the fix for java/23891, a 4.0 regression, to the 4.0
branch. It also updates jacks.xfail. I'm checking this in.
See: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23891
Bryce
2005-10-01 Bryce McKinlay <mckinlay@redhat.com>
* testsuite/libjava.jacks/jacks.xfail: Update to reflect
PR java/23891 fix.
2005-10-01 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'.
* class.c (maybe_layout_super_class): Update current_class before
calling do_resolve_class.
Index: gcc/java/class.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/class.c,v
retrieving revision 1.220.8.5
diff -u -r1.220.8.5 class.c
--- gcc/java/class.c 17 Aug 2005 22:08:15 -0000 1.220.8.5
+++ gcc/java/class.c 1 Oct 2005 06:14:22 -0000
@@ -2060,6 +2060,9 @@
super_class = TREE_TYPE (super_class);
else
{
+ /* Set the correct context for class resolution. */
+ current_class = this_class;
+
/* do_resolve_class expects an EXPR_WITH_FILE_LOCATION, so
we give it one. */
tree this_wrap = NULL_TREE;
Index: gcc/java/java-tree.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/java-tree.h,v
retrieving revision 1.226.8.2
diff -u -r1.226.8.2 java-tree.h
--- gcc/java/java-tree.h 6 Jun 2005 19:20:57 -0000 1.226.8.2
+++ gcc/java/java-tree.h 1 Oct 2005 06:14:25 -0000
@@ -1111,6 +1111,7 @@
#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(())
{
@@ -1159,6 +1160,9 @@
/* 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. */
Index: gcc/java/jcf-parse.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/jcf-parse.c,v
retrieving revision 1.183
diff -u -r1.183 jcf-parse.c
--- gcc/java/jcf-parse.c 12 Feb 2005 15:21:14 -0000 1.183
+++ gcc/java/jcf-parse.c 1 Oct 2005 06:14:26 -0000
@@ -444,6 +444,7 @@
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 @@
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;
}
}
Index: gcc/java/parse.y
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/parse.y,v
retrieving revision 1.528.6.3
diff -u -r1.528.6.3 parse.y
--- gcc/java/parse.y 17 Aug 2005 12:57:04 -0000 1.528.6.3
+++ gcc/java/parse.y 1 Oct 2005 06:14:32 -0000
@@ -3919,6 +3919,14 @@
/* 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;
@@ -4193,12 +4201,6 @@
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. */
@@ -5672,6 +5674,9 @@
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);
@@ -5979,8 +5984,10 @@
/* 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))))
+ /* printf ("cc= %s\n", current_class ? IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME
+ (current_class))) : "null"); */
+ if ((new_class_decl = qualify_and_find (class_type,
+ TYPE_PACKAGE (current_class), TYPE_NAME (class_type))))
return new_class_decl;
}
@@ -10370,37 +10377,11 @@
/* 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;
}
Index: libjava/testsuite/libjava.jacks/jacks.xfail
===================================================================
RCS file: /cvs/gcc/gcc/libjava/testsuite/libjava.jacks/jacks.xfail,v
retrieving revision 1.19.8.1
diff -u -r1.19.8.1 jacks.xfail
--- libjava/testsuite/libjava.jacks/jacks.xfail 17 Aug 2005 12:57:01 -0000 1.19.8.1
+++ libjava/testsuite/libjava.jacks/jacks.xfail 1 Oct 2005 06:14:35 -0000
@@ -152,8 +152,8 @@
15.11.2-syntax-1
15.12.1-syntax-1
15.12.1-type-14
-15.12.2.1-accessibility-method-2
-15.12.2.1-accessibility-method-4
+15.12.2.1-accessibility-method-3
+15.12.2.1-accessibility-method-5
15.12.2.1-accessibility-method-6
15.12.2.2-ambiguous-10
15.12.2.2-ambiguous-12
@@ -329,6 +329,7 @@
15.9.1-qualified-concrete-12
15.9.1-qualified-concrete-14
15.9.1-qualified-concrete-16
+15.9.1-qualified-concrete-24
15.9.1-qualified-concrete-4
15.9.1-qualified-concrete-5
15.9.1-unqualified-anonymous-12