+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
being used, and the USING_DECL, or NULL_TREE on failure. */
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)
{
- *name = TREE_OPERAND (decl, 0);
/* 7.3.3/5
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;
}
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]
A using-declaration for a class member shall be a
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;
}
- *name = DECL_NAME (decl);
+
/* Make a USING_DECL. */
- return push_using_decl (*scope, *name);
+ return push_using_decl (scope, name);
}
/* Process local and global using-declarations. */
/* Process a using-declaration at function scope. */
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;
- decl = validate_nonmember_using_decl (decl, &scope, &name);
+ decl = validate_nonmember_using_decl (decl, scope, name);
if (decl == NULL_TREE)
return;
/* Process a using-declaration not appearing in class or local scope. */
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;
cxx_binding *binding;
- decl = validate_nonmember_using_decl (decl, &scope, &name);
+ decl = validate_nonmember_using_decl (decl, scope, name);
if (decl == NULL_TREE)
return;
extern void push_decl_namespace (tree);
extern void pop_decl_namespace (void);
extern void do_namespace_alias (tree, tree);
-extern void do_toplevel_using_decl (tree);
-extern void do_local_using_decl (tree);
+extern void do_toplevel_using_decl (tree, tree, tree);
+extern void do_local_using_decl (tree, tree, tree);
extern tree do_class_using_decl (tree);
extern void do_using_directive (tree);
extern tree lookup_arg_dependent (tree, tree, tree);
tree decl;
tree identifier;
tree scope;
+ tree qscope;
/* Look for the `using' keyword. */
cp_parser_require_keyword (parser, RID_USING, "`using'");
/* If we saw `typename', or didn't see `::', then there must be a
nested-name-specifier present. */
if (typename_p || !global_scope_p)
- cp_parser_nested_name_specifier (parser, typename_p,
- /*check_dependency_p=*/true,
- /*type_p=*/false,
- /*is_declaration=*/true);
+ qscope = cp_parser_nested_name_specifier (parser, typename_p,
+ /*check_dependency_p=*/true,
+ /*type_p=*/false,
+ /*is_declaration=*/true);
/* Otherwise, we could be in either of the two productions. In that
case, treat the nested-name-specifier as optional. */
else
- cp_parser_nested_name_specifier_opt (parser,
- /*typename_keyword_p=*/false,
- /*check_dependency_p=*/true,
- /*type_p=*/false,
- /*is_declaration=*/true);
+ qscope = cp_parser_nested_name_specifier_opt (parser,
+ /*typename_keyword_p=*/false,
+ /*check_dependency_p=*/true,
+ /*type_p=*/false,
+ /*is_declaration=*/true);
+ if (!qscope)
+ qscope = global_namespace;
/* Parse the unqualified-id. */
identifier = cp_parser_unqualified_id (parser,
if (decl == error_mark_node)
cp_parser_name_lookup_error (parser, identifier, decl, NULL);
else if (scope)
- do_local_using_decl (decl);
+ do_local_using_decl (decl, qscope, identifier);
else
- do_toplevel_using_decl (decl);
+ do_toplevel_using_decl (decl, qscope, identifier);
}
}
if (decl == error_mark_node)
qualified_name_lookup_error (scope, name);
else
- do_local_using_decl (decl);
+ do_local_using_decl (decl, scope, name);
}
else
{