diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 1abd30d818d..85e8e05490c 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,13 @@ 1998-07-16 Jason Merrill + * init.c (build_offset_ref): Don't call mark_used on an OVERLOAD. + * decl.c (select_decl): Extract a lone function from an OVERLOAD. + (lookup_namespace_name): Likewise. + * typeck.c (build_unary_op): Not here anymore. + + * decl2.c (do_class_using_decl): Make sure we get an identifier. + * class.c (handle_using_decl): Ignore TYPE_DECLs. + * decl.c (qualify_lookup): New fn. (lookup_name_real): Use it. diff --git a/gcc/cp/class.c b/gcc/cp/class.c index cc536716630..1c98b3b4e4d 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -1381,6 +1381,10 @@ handle_using_decl (using_decl, t, method_vec, fields) OVL_CURRENT (TREE_VEC_ELT (method_vec, i))); return; } + + if (! DECL_LANG_SPECIFIC (fdecl)) + /* We don't currently handle DECL_ACCESS for TYPE_DECLs; just return. */ + return; for (tmp = fields; tmp; tmp = TREE_CHAIN (tmp)) if (DECL_NAME (tmp) == name) diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 0801ab83a86..8071386c22a 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -4650,7 +4650,15 @@ lookup_namespace_name (namespace, name) return error_mark_node; if (BINDING_VALUE (val)) - return BINDING_VALUE (val); + { + val = BINDING_VALUE (val); + + /* If we have a single function from a using decl, pull it out. */ + if (TREE_CODE (val) == OVERLOAD && ! really_overloaded_fn (val)) + val = OVL_FUNCTION (val); + return val; + } + cp_error ("`%D' undeclared in namespace `%D'", name, namespace); return error_mark_node; } @@ -4760,6 +4768,11 @@ select_decl (binding, flags) else if (val && LOOKUP_TYPES_ONLY (flags) && TREE_CODE (val) != TYPE_DECL && (!looking_for_template || TREE_CODE (val) != TEMPLATE_DECL)) val = NULL_TREE; + + /* If we have a single function from a using decl, pull it out. */ + if (val && TREE_CODE (val) == OVERLOAD && ! really_overloaded_fn (val)) + val = OVL_FUNCTION (val); + return val; } diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c index bd32d627dbc..5384e98e066 100644 --- a/gcc/cp/decl2.c +++ b/gcc/cp/decl2.c @@ -3985,7 +3985,7 @@ ambiguous_decl (name, old, new, flags) type = NULL_TREE; if (!BINDING_TYPE (old)) BINDING_TYPE (old) = type; - else if(type && BINDING_TYPE (old) != type) + else if (type && BINDING_TYPE (old) != type) { if (flags & LOOKUP_COMPLAIN) { @@ -4604,6 +4604,10 @@ do_class_using_decl (decl) cp_error ("using-declaration for destructor"); return NULL_TREE; } + if (TREE_CODE (name) == TYPE_DECL) + name = DECL_NAME (name); + + my_friendly_assert (TREE_CODE (name) == IDENTIFIER_NODE, 980716); value = build_lang_field_decl (USING_DECL, name, void_type_node); DECL_INITIAL (value) = TREE_OPERAND (decl, 0); diff --git a/gcc/cp/init.c b/gcc/cp/init.c index 2f807997156..dfe07b5239a 100644 --- a/gcc/cp/init.c +++ b/gcc/cp/init.c @@ -1540,8 +1540,12 @@ build_offset_ref (type, name) if (TREE_CODE (type) == NAMESPACE_DECL) { t = lookup_namespace_name (type, name); - mark_used (t); - return convert_from_reference (t); + if (! type_unknown_p (t)) + { + mark_used (t); + t = convert_from_reference (t); + } + return t; } if (type == NULL_TREE || ! is_aggr_type (type, 1)) diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index 644260aad4f..2c1421eecfa 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -4547,14 +4547,6 @@ build_unary_op (code, xarg, noconvert) return build1 (ADDR_EXPR, unknown_type_node, arg); } - /* If we have a single function from a using decl, pull it out. */ - if (TREE_CODE (arg) == OVERLOAD - && ! really_overloaded_fn (arg)) - { - arg = OVL_FUNCTION (arg); - argtype = TREE_TYPE (arg); - } - if (TREE_CODE (arg) == OVERLOAD || (TREE_CODE (arg) == OFFSET_REF && TREE_CODE (TREE_OPERAND (arg, 1)) == TEMPLATE_ID_EXPR))