This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
[gcjx] Patch: FYI: fix in static import resolution
- From: Tom Tromey <tromey at redhat dot com>
- To: Java Patch List <java-patches at gcc dot gnu dot org>
- Date: 12 Feb 2005 20:24:43 -0700
- Subject: [gcjx] Patch: FYI: fix in static import resolution
- Reply-to: tromey at redhat dot com
I'm checking this in on the gcjx branch.
This fixes a bug where, when resolving a static import, we failed to
check to see that the import actually named a static member.
Tom
#
# patch "gcc/gcjx/ChangeLog"
# from [67c5472b859457a71772915793d4f251cfcca1c0]
# to [d62003800daa04399c7ce22ba417bd3e97e33d45]
#
# patch "gcc/gcjx/model/import.cc"
# from [61aa9064dbd3e686e58adc1f1089ae7109ea8088]
# to [fcd2a4fa53a3ea1456447dc4bf7e7e87d3a3f8aa]
#
# patch "gcc/gcjx/model/import.hh"
# from [6a760fcd94d6a5460f65987f1d545e658117aa70]
# to [0e9ff6c9a78335134ded41fb89fb3fe566d7ceb6]
#
--- gcc/gcjx/ChangeLog
+++ gcc/gcjx/ChangeLog
@@ -1,5 +1,8 @@
2005-02-04 Tom Tromey <tromey@redhat.com>
+ * model/import.cc (resolve): New method.
+ * model/import.hh (model_static_import_single::resolve): Declare.
+
* model/unit.cc (resolve): Indentation fixes.
* bytecode/signature.cc (parse_ref_type): End inner loop when ';'
--- gcc/gcjx/model/import.cc
+++ gcc/gcjx/model/import.cc
@@ -1,6 +1,6 @@
// Import statements.
-// Copyright (C) 2004 Free Software Foundation, Inc.
+// Copyright (C) 2004, 2005 Free Software Foundation, Inc.
//
// This file is part of GCC.
//
@@ -189,6 +189,36 @@
return search_for_class (member_name);
}
+void
+model_static_import_single::resolve (resolution_scope *scope)
+{
+ model_static_import_base::resolve (scope);
+
+ // Make sure we imported something.
+ // FIXME: don't we need to use the canonical name?
+
+ {
+ std::set<model_variable_decl *> fields;
+ find_field (member_name, scope->get_current_context (), fields);
+ if (! fields.empty ())
+ return;
+ }
+
+ {
+ std::set<model_method *> methods;
+ find_method (member_name, scope->get_current_context (), methods);
+ if (! methods.empty ())
+ return;
+ }
+
+ if (get_class_declaration () != NULL)
+ return;
+
+ // If we got here, there's no member.
+ throw error ("%1 does not name a static member in %2")
+ % member_name % resolved_type;
+}
+
model_class *
model_static_import_single::find_class (const std::string &name)
{
--- gcc/gcjx/model/import.hh
+++ gcc/gcjx/model/import.hh
@@ -1,6 +1,6 @@
// Represent an import statement.
-// Copyright (C) 2004 Free Software Foundation, Inc.
+// Copyright (C) 2004, 2005 Free Software Foundation, Inc.
//
// This file is part of GCC.
//
@@ -193,6 +193,8 @@
member_name = ::get_simple_name (n);
}
+ void resolve (resolution_scope *);
+
model_class *find_class (const std::string &name);
void find_field (const std::string &, IContext *,