]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/13659 (error: no matching function for call to)
authorAlexandre Oliva <aoliva@redhat.com>
Thu, 15 Jan 2004 14:45:15 +0000 (14:45 +0000)
committerAlexandre Oliva <aoliva@gcc.gnu.org>
Thu, 15 Jan 2004 14:45:15 +0000 (14:45 +0000)
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

gcc/cp/ChangeLog
gcc/cp/name-lookup.c
gcc/cp/name-lookup.h
gcc/cp/parser.c
gcc/cp/pt.c

index 2edab86495f92c004bbaee80439f06ce395f2bb1..91345672750b085da73bd7b83112c67fd0c3b49d 100644 (file)
@@ -1,3 +1,15 @@
+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
index 91f6466465c441103e6aae3a0dccd68d64a9f2f4..4893e5ebda096431a1dc870339a62d0179922dcf 100644 (file)
@@ -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;
   
index 8c8b04057f6110414b1c4bc26e25848aeb178115..fa95729070ae9a1347f0ce53a2870113456acf7e 100644 (file)
@@ -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);
index 31c327ad415ace803b418a874350d4f6e47671d0..6a78264421a8831f957d9afab004991c0d1173ac 100644 (file)
@@ -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);
        }
     }
 
index faaeaa2f24c517c5ee709b1d4c0a52e925fd2f31..0701c5bb982fbffe05447aa90c2a230f14be541f 100644 (file)
@@ -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
          {