summaryrefslogtreecommitdiff
path: root/gcc/cp/search.c
diff options
context:
space:
mode:
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>2011-11-14 17:55:57 +0000
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>2011-11-14 17:55:57 +0000
commit807f85cfb63c455ad591e9786293e05fe725b9ab (patch)
treef07e77967d125d0ff0d7a38837f5d8b94e0bf38f /gcc/cp/search.c
parent811fd2b8d92f4d89c07aeb958da2b623f3908926 (diff)
downloadgcc-807f85cfb63c455ad591e9786293e05fe725b9ab.tar.gz
PR c++/6936
PR c++/25994 PR c++/26256 PR c++/30195 * search.c (lookup_field_1): Look through USING_DECL. (lookup_field_r): Call lookup_fnfields_slot instead of lookup_fnfields_1. * semantics.c (finish_member_declaration): Remove the check that prevents USING_DECLs from being verified by pushdecl_class_level. Call add_method for using declarations that designates functions if the using declaration is in a template class. Set DECL_IGNORED_P on class-scope using declarations. * typeck.c (build_class_member_access_expr): Handle USING_DECLs. * class.c (check_field_decls): Keep using declarations. (add_method): Remove two diagnostics about conflicting using declarations. * parser.c (cp_parser_nonclass_name): Handle USING_DECLs. * decl.c (start_enum): Call xref_tag whenever possible. * cp-tree.h (strip_using_decl): Declare, and reident the previous function. * name-lookup.c (strip_using_decl): New function. (supplement_binding_1): Call strip_using_decl on decl and bval. Perform most of the checks with USING_DECLs stripped. Also check that the target decl and the target bval does not refer to the same declaration. Allow pushing an enum multiple times in a template class. Adjustment to diagnose using redeclarations. Call diagnose_name_conflict. (push_class_level_binding): Call strip_using_decl on decl and bval. Perform most of the checks with USING_DECLs stripped. Return true if both decl and bval refer to USING_DECLs and are dependent. (diagnose_name_conflict): New function. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@181359 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cp/search.c')
-rw-r--r--gcc/cp/search.c34
1 files changed, 13 insertions, 21 deletions
diff --git a/gcc/cp/search.c b/gcc/cp/search.c
index 7d9551c28bf..9f308e29d79 100644
--- a/gcc/cp/search.c
+++ b/gcc/cp/search.c
@@ -1,7 +1,7 @@
/* Breadth-first and depth-first routines for
searching multiple-inheritance lattice for GNU C++.
Copyright (C) 1987, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
- 1999, 2000, 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010
+ 1999, 2000, 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010, 2011
Free Software Foundation, Inc.
Contributed by Michael Tiemann (tiemann@cygnus.com)
@@ -449,6 +449,8 @@ lookup_field_1 (tree type, tree name, bool want_type)
#endif /* GATHER_STATISTICS */
for (field = TYPE_FIELDS (type); field; field = DECL_CHAIN (field))
{
+ tree decl = field;
+
#ifdef GATHER_STATISTICS
n_fields_searched++;
#endif /* GATHER_STATISTICS */
@@ -460,26 +462,20 @@ lookup_field_1 (tree type, tree name, bool want_type)
if (temp)
return temp;
}
- if (TREE_CODE (field) == USING_DECL)
+
+ if (TREE_CODE (decl) == USING_DECL
+ && DECL_NAME (decl) == name)
{
- /* We generally treat class-scope using-declarations as
- ARM-style access specifications, because support for the
- ISO semantics has not been implemented. So, in general,
- there's no reason to return a USING_DECL, and the rest of
- the compiler cannot handle that. Once the class is
- defined, USING_DECLs are purged from TYPE_FIELDS; see
- handle_using_decl. However, we make special efforts to
- make using-declarations in class templates and class
- template partial specializations work correctly. */
- if (!DECL_DEPENDENT_P (field))
+ decl = strip_using_decl (decl);
+ if (is_overloaded_fn (decl))
continue;
}
- if (DECL_NAME (field) == name
+ if (DECL_NAME (decl) == name
&& (!want_type
- || TREE_CODE (field) == TYPE_DECL
- || DECL_TYPE_TEMPLATE_P (field)))
- return field;
+ || TREE_CODE (decl) == TYPE_DECL
+ || DECL_TYPE_TEMPLATE_P (decl)))
+ return decl;
}
/* Not found. */
if (name == vptr_identifier)
@@ -1028,11 +1024,7 @@ lookup_field_r (tree binfo, void *data)
member with the same name, and if there's a function and a type
with the same name, the type is hidden by the function. */
if (!lfi->want_type)
- {
- int idx = lookup_fnfields_1 (type, lfi->name);
- if (idx >= 0)
- nval = VEC_index (tree, CLASSTYPE_METHOD_VEC (type), idx);
- }
+ nval = lookup_fnfields_slot (type, lfi->name);
if (!nval)
/* Look for a data member or type. */