diff options
author | Alexandre Oliva <aoliva@redhat.com> | 2004-01-15 14:45:15 +0000 |
---|---|---|
committer | Alexandre Oliva <aoliva@redhat.com> | 2004-01-15 14:45:15 +0000 |
commit | 4912df96be3b7cb3c1f36112dacae0a26fd2619d (patch) | |
tree | 2a56d57a7ff749ac5a954ddde64f4b44d9d18a9d | |
parent | 5c1c23e11c3abdc83cf2354cd8bd048db73c47e8 (diff) |
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.
git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@75923 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r-- | gcc/cp/ChangeLog | 12 | ||||
-rw-r--r-- | gcc/cp/name-lookup.c | 34 | ||||
-rw-r--r-- | gcc/cp/name-lookup.h | 4 | ||||
-rw-r--r-- | gcc/cp/parser.c | 25 | ||||
-rw-r--r-- | gcc/cp/pt.c | 2 |
5 files changed, 39 insertions, 38 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 2edab86495f..91345672750 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,17 @@ 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++/13658 * name-lookup.c (qualified_lookup_using_namespace): Search diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c index 91f6466465c..4893e5ebda0 100644 --- a/gcc/cp/name-lookup.c +++ b/gcc/cp/name-lookup.c @@ -2071,17 +2071,13 @@ push_overloaded_decl (tree decl, int flags) 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; } @@ -2104,25 +2100,17 @@ validate_nonmember_using_decl (tree decl, tree *scope, tree *name) 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. */ @@ -2235,12 +2223,11 @@ do_nonmember_using_decl (tree scope, tree name, tree oldval, tree oldtype, /* 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; @@ -3248,13 +3235,12 @@ add_using_namespace (tree user, tree used, bool indirect) /* 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; diff --git a/gcc/cp/name-lookup.h b/gcc/cp/name-lookup.h index 8c8b04057f6..fa95729070a 100644 --- a/gcc/cp/name-lookup.h +++ b/gcc/cp/name-lookup.h @@ -301,8 +301,8 @@ extern tree current_decl_namespace (void); 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); diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 31c327ad415..6a78264421a 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -9414,6 +9414,7 @@ cp_parser_using_declaration (cp_parser* parser) tree decl; tree identifier; tree scope; + tree qscope; /* Look for the `using' keyword. */ cp_parser_require_keyword (parser, RID_USING, "`using'"); @@ -9438,18 +9439,20 @@ cp_parser_using_declaration (cp_parser* parser) /* 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, @@ -9485,9 +9488,9 @@ cp_parser_using_declaration (cp_parser* 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); } } diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index faaeaa2f24c..0701c5bb982 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -7695,7 +7695,7 @@ tsubst_expr (tree t, tree args, tsubst_flags_t complain, tree in_decl) 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 { |