summaryrefslogtreecommitdiff
path: root/gcc/cp/search.c
diff options
context:
space:
mode:
authornathan <nathan@138bc75d-0d04-0410-961f-82ee72b054a4>2003-04-20 11:48:36 +0000
committernathan <nathan@138bc75d-0d04-0410-961f-82ee72b054a4>2003-04-20 11:48:36 +0000
commit03c8911ca0554955d34dc4dc439cd50b705c0134 (patch)
treee581bf7754f4355768ae4c9b814d1df04746f00e /gcc/cp/search.c
parent2cbf1359092416d271b02844198e7ad6e5e56284 (diff)
downloadgcc-03c8911ca0554955d34dc4dc439cd50b705c0134.tar.gz
cp:
PR c++/10405 * search.c (lookup_field_1): Final scan goes backwards for types, forwards for non-types. testsuite: PR c++/10405 * g++.dg/lookup/struct-hack1.C: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@65846 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cp/search.c')
-rw-r--r--gcc/cp/search.c26
1 files changed, 15 insertions, 11 deletions
diff --git a/gcc/cp/search.c b/gcc/cp/search.c
index 9fc84311d38..433e1ac13ae 100644
--- a/gcc/cp/search.c
+++ b/gcc/cp/search.c
@@ -472,19 +472,23 @@ lookup_field_1 (tree type, tree name, bool want_type)
/* We might have a nested class and a field with the
same name; we sorted them appropriately via
- field_decl_cmp, so just look for the last field with
- this name. */
- while (true)
+ field_decl_cmp, so just look for the first or last
+ field with this name. */
+ if (want_type)
{
- if (!want_type
- || TREE_CODE (fields[i]) == TYPE_DECL
- || DECL_CLASS_TEMPLATE_P (fields[i]))
- field = fields[i];
- if (i + 1 == hi || DECL_NAME (fields[i+1]) != name)
- break;
- i++;
+ do
+ field = fields[i--];
+ while (i >= lo && DECL_NAME (fields[i]) == name);
+ if (TREE_CODE (field) != TYPE_DECL
+ && !DECL_CLASS_TEMPLATE_P (field))
+ field = NULL_TREE;
+ }
+ else
+ {
+ do
+ field = fields[i++];
+ while (i < hi && DECL_NAME (fields[i]) == name);
}
-
return field;
}
}