Commit ed5f054f by Alexandre Oliva Committed by Alexandre Oliva

re PR c++/13659 (error: no matching function for call to)

PR c++/13659
* name-lookup.c (validate_nonmember_using_decl): Take scope and
name by value, instead of computing them.
(do_local_using_decl, do_toplevel_using_decl): Add scope and name
arguments.  Pass them to validate_nonmember_using_decl.
* name-lookup.h (do_local_using_decl): Adjust.
(do_toplevel_using_decl): Likewise.
* parser.c (cp_parser_using_declaration): Likewise.
* pt.c (tsubst_expr): Likewise.

From-SVN: r75923
parent 693ec7e1
2004-01-15 Alexandre Oliva <aoliva@redhat.com> 2004-01-15 Alexandre Oliva <aoliva@redhat.com>
PR c++/13659
* name-lookup.c (validate_nonmember_using_decl): Take scope and
name by value, instead of computing them.
(do_local_using_decl, do_toplevel_using_decl): Add scope and name
arguments. Pass them to validate_nonmember_using_decl.
* name-lookup.h (do_local_using_decl): Adjust.
(do_toplevel_using_decl): Likewise.
* parser.c (cp_parser_using_declaration): Likewise.
* pt.c (tsubst_expr): Likewise.
2004-01-15 Alexandre Oliva <aoliva@redhat.com>
PR c++/13594 PR c++/13594
PR c++/13658 PR c++/13658
* name-lookup.c (qualified_lookup_using_namespace): Search * name-lookup.c (qualified_lookup_using_namespace): Search
......
...@@ -2071,17 +2071,13 @@ push_overloaded_decl (tree decl, int flags) ...@@ -2071,17 +2071,13 @@ push_overloaded_decl (tree decl, int flags)
being used, and the USING_DECL, or NULL_TREE on failure. */ being used, and the USING_DECL, or NULL_TREE on failure. */
static tree static tree
validate_nonmember_using_decl (tree decl, tree *scope, tree *name) validate_nonmember_using_decl (tree decl, tree scope, tree name)
{ {
*scope = global_namespace;
*name = NULL_TREE;
if (TREE_CODE (decl) == TEMPLATE_ID_EXPR) if (TREE_CODE (decl) == TEMPLATE_ID_EXPR)
{ {
*name = TREE_OPERAND (decl, 0);
/* 7.3.3/5 /* 7.3.3/5
A using-declaration shall not name a template-id. */ A using-declaration shall not name a template-id. */
error ("a using-declaration cannot specify a template-id. Try `using %D'", *name); error ("a using-declaration cannot specify a template-id. Try `using %D'", name);
return NULL_TREE; return NULL_TREE;
} }
...@@ -2104,25 +2100,17 @@ validate_nonmember_using_decl (tree decl, tree *scope, tree *name) ...@@ -2104,25 +2100,17 @@ validate_nonmember_using_decl (tree decl, tree *scope, tree *name)
my_friendly_assert (DECL_P (decl), 20020908); my_friendly_assert (DECL_P (decl), 20020908);
if (TREE_CODE (decl) == CONST_DECL)
/* Enumeration constants to not have DECL_CONTEXT set. */
*scope = TYPE_CONTEXT (TREE_TYPE (decl));
else
*scope = DECL_CONTEXT (decl);
if (!*scope)
*scope = global_namespace;
/* [namespace.udecl] /* [namespace.udecl]
A using-declaration for a class member shall be a A using-declaration for a class member shall be a
member-declaration. */ member-declaration. */
if (TYPE_P (*scope)) if (TYPE_P (scope))
{ {
error ("`%T' is not a namespace", *scope); error ("`%T' is not a namespace", scope);
return NULL_TREE; return NULL_TREE;
} }
*name = DECL_NAME (decl);
/* Make a USING_DECL. */ /* Make a USING_DECL. */
return push_using_decl (*scope, *name); return push_using_decl (scope, name);
} }
/* Process local and global using-declarations. */ /* Process local and global using-declarations. */
...@@ -2235,12 +2223,11 @@ do_nonmember_using_decl (tree scope, tree name, tree oldval, tree oldtype, ...@@ -2235,12 +2223,11 @@ do_nonmember_using_decl (tree scope, tree name, tree oldval, tree oldtype,
/* Process a using-declaration at function scope. */ /* Process a using-declaration at function scope. */
void void
do_local_using_decl (tree decl) do_local_using_decl (tree decl, tree scope, tree name)
{ {
tree scope, name;
tree oldval, oldtype, newval, newtype; tree oldval, oldtype, newval, newtype;
decl = validate_nonmember_using_decl (decl, &scope, &name); decl = validate_nonmember_using_decl (decl, scope, name);
if (decl == NULL_TREE) if (decl == NULL_TREE)
return; return;
...@@ -3248,13 +3235,12 @@ add_using_namespace (tree user, tree used, bool indirect) ...@@ -3248,13 +3235,12 @@ add_using_namespace (tree user, tree used, bool indirect)
/* Process a using-declaration not appearing in class or local scope. */ /* Process a using-declaration not appearing in class or local scope. */
void void
do_toplevel_using_decl (tree decl) do_toplevel_using_decl (tree decl, tree scope, tree name)
{ {
tree scope, name;
tree oldval, oldtype, newval, newtype; tree oldval, oldtype, newval, newtype;
cxx_binding *binding; cxx_binding *binding;
decl = validate_nonmember_using_decl (decl, &scope, &name); decl = validate_nonmember_using_decl (decl, scope, name);
if (decl == NULL_TREE) if (decl == NULL_TREE)
return; return;
......
...@@ -301,8 +301,8 @@ extern tree current_decl_namespace (void); ...@@ -301,8 +301,8 @@ extern tree current_decl_namespace (void);
extern void push_decl_namespace (tree); extern void push_decl_namespace (tree);
extern void pop_decl_namespace (void); extern void pop_decl_namespace (void);
extern void do_namespace_alias (tree, tree); extern void do_namespace_alias (tree, tree);
extern void do_toplevel_using_decl (tree); extern void do_toplevel_using_decl (tree, tree, tree);
extern void do_local_using_decl (tree); extern void do_local_using_decl (tree, tree, tree);
extern tree do_class_using_decl (tree); extern tree do_class_using_decl (tree);
extern void do_using_directive (tree); extern void do_using_directive (tree);
extern tree lookup_arg_dependent (tree, tree, tree); extern tree lookup_arg_dependent (tree, tree, tree);
......
...@@ -9414,6 +9414,7 @@ cp_parser_using_declaration (cp_parser* parser) ...@@ -9414,6 +9414,7 @@ cp_parser_using_declaration (cp_parser* parser)
tree decl; tree decl;
tree identifier; tree identifier;
tree scope; tree scope;
tree qscope;
/* Look for the `using' keyword. */ /* Look for the `using' keyword. */
cp_parser_require_keyword (parser, RID_USING, "`using'"); cp_parser_require_keyword (parser, RID_USING, "`using'");
...@@ -9438,18 +9439,20 @@ cp_parser_using_declaration (cp_parser* parser) ...@@ -9438,18 +9439,20 @@ cp_parser_using_declaration (cp_parser* parser)
/* If we saw `typename', or didn't see `::', then there must be a /* If we saw `typename', or didn't see `::', then there must be a
nested-name-specifier present. */ nested-name-specifier present. */
if (typename_p || !global_scope_p) if (typename_p || !global_scope_p)
cp_parser_nested_name_specifier (parser, typename_p, qscope = cp_parser_nested_name_specifier (parser, typename_p,
/*check_dependency_p=*/true, /*check_dependency_p=*/true,
/*type_p=*/false, /*type_p=*/false,
/*is_declaration=*/true); /*is_declaration=*/true);
/* Otherwise, we could be in either of the two productions. In that /* Otherwise, we could be in either of the two productions. In that
case, treat the nested-name-specifier as optional. */ case, treat the nested-name-specifier as optional. */
else else
cp_parser_nested_name_specifier_opt (parser, qscope = cp_parser_nested_name_specifier_opt (parser,
/*typename_keyword_p=*/false, /*typename_keyword_p=*/false,
/*check_dependency_p=*/true, /*check_dependency_p=*/true,
/*type_p=*/false, /*type_p=*/false,
/*is_declaration=*/true); /*is_declaration=*/true);
if (!qscope)
qscope = global_namespace;
/* Parse the unqualified-id. */ /* Parse the unqualified-id. */
identifier = cp_parser_unqualified_id (parser, identifier = cp_parser_unqualified_id (parser,
...@@ -9485,9 +9488,9 @@ cp_parser_using_declaration (cp_parser* parser) ...@@ -9485,9 +9488,9 @@ cp_parser_using_declaration (cp_parser* parser)
if (decl == error_mark_node) if (decl == error_mark_node)
cp_parser_name_lookup_error (parser, identifier, decl, NULL); cp_parser_name_lookup_error (parser, identifier, decl, NULL);
else if (scope) else if (scope)
do_local_using_decl (decl); do_local_using_decl (decl, qscope, identifier);
else else
do_toplevel_using_decl (decl); do_toplevel_using_decl (decl, qscope, identifier);
} }
} }
......
...@@ -7695,7 +7695,7 @@ tsubst_expr (tree t, tree args, tsubst_flags_t complain, tree in_decl) ...@@ -7695,7 +7695,7 @@ tsubst_expr (tree t, tree args, tsubst_flags_t complain, tree in_decl)
if (decl == error_mark_node) if (decl == error_mark_node)
qualified_name_lookup_error (scope, name); qualified_name_lookup_error (scope, name);
else else
do_local_using_decl (decl); do_local_using_decl (decl, scope, name);
} }
else else
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment