PR libstdc++/24660
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 12 Jan 2006 20:10:47 +0000 (20:10 +0000)
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 12 Jan 2006 20:10:47 +0000 (20:10 +0000)
        * pt.c (check_explicit_specialization): Handle namespace
        association.
        * name-lookup.c (set_decl_namespace): Likewise.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@109647 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/cp/ChangeLog
gcc/cp/name-lookup.c
gcc/cp/pt.c
gcc/doc/extend.texi

index 62bb3aa..458c3c7 100644 (file)
@@ -1,3 +1,10 @@
+2006-01-12  Jason Merrill  <jason@redhat.com>
+
+       PR libstdc++/24660
+       * pt.c (check_explicit_specialization): Handle namespace
+       association.
+       * name-lookup.c (set_decl_namespace): Likewise.
+
 2006-01-12  Nathan Sidwell  <nathan@codesourcery.com>
 
        PR c++/24824
index ec662e6..96ce4a7 100644 (file)
@@ -2844,7 +2844,7 @@ set_namespace_binding (tree name, tree scope, tree val)
 void
 set_decl_namespace (tree decl, tree scope, bool friendp)
 {
-  tree old;
+  tree old, fn;
 
   /* Get rid of namespace aliases.  */
   scope = ORIGINAL_NAMESPACE (scope);
@@ -2865,13 +2865,10 @@ set_decl_namespace (tree decl, tree scope, bool friendp)
     }
 
   /* See whether this has been declared in the namespace.  */
-  old = namespace_binding (DECL_NAME (decl), scope);
+  old = lookup_qualified_name (scope, DECL_NAME (decl), false, true);
   if (!old)
     /* No old declaration at all.  */
     goto complain;
-  /* A template can be explicitly specialized in any namespace.  */
-  if (processing_explicit_instantiation)
-    return;
   if (!is_overloaded_fn (decl))
     /* Don't compare non-function decls with decls_match here, since
        it can't check for the correct constness at this
@@ -2880,6 +2877,12 @@ set_decl_namespace (tree decl, tree scope, bool friendp)
   /* Since decl is a function, old should contain a function decl.  */
   if (!is_overloaded_fn (old))
     goto complain;
+  fn = OVL_CURRENT (old);
+  if (!is_associated_namespace (scope, DECL_CONTEXT (fn)))
+    goto complain;
+  /* A template can be explicitly specialized in any namespace.  */
+  if (processing_explicit_instantiation)
+    return;
   if (processing_template_decl || processing_specialization)
     /* We have not yet called push_template_decl to turn a
        FUNCTION_DECL into a TEMPLATE_DECL, so the declarations won't
index 5b025ce..3afe45d 100644 (file)
@@ -1901,12 +1901,19 @@ check_explicit_specialization (tree declarator,
 
              /* Find the namespace binding, using the declaration
                 context.  */
-             fns = namespace_binding (dname, CP_DECL_CONTEXT (decl));
+             fns = lookup_qualified_name (current_namespace, dname,
+                                          false, true);
              if (!fns || !is_overloaded_fn (fns))
                {
                  error ("%qD is not a template function", dname);
                  fns = error_mark_node;
                }
+             else
+               {
+                 tree fn = OVL_CURRENT (fns);
+                 if (!is_associated_namespace (current_namespace, DECL_CONTEXT (fn)))
+                   error ("%qD is not declared in %qD", decl, current_namespace);
+               }
            }
 
          declarator = lookup_template_function (fns, NULL_TREE);
index 0d54654..0c2f39c 100644 (file)
@@ -9864,7 +9864,7 @@ Predefined Macros,cpp,The GNU C Preprocessor}).
 * Bound member functions:: You can extract a function pointer to the
                         method denoted by a @samp{->*} or @samp{.*} expression.
 * C++ Attributes::      Variable, function, and type attributes for C++ only.
-* Strong Using::      Strong using-directives for namespace composition.
+* Namespace Association:: Strong using-directives for namespace association.
 * Java Exceptions::     Tweaking exception handling to work with Java.
 * Deprecated Features:: Things will disappear from g++.
 * Backwards Compatibility:: Compatibilities with earlier definitions of C++.
@@ -10402,22 +10402,23 @@ interface table mechanism, instead of regular virtual table dispatch.
 
 @end table
 
-See also @xref{Strong Using}.
+See also @xref{Namespace Association}.
 
-@node Strong Using
-@section Strong Using
+@node Namespace Association
+@section Namespace Association
 
 @strong{Caution:} The semantics of this extension are not fully
 defined.  Users should refrain from using this extension as its
 semantics may change subtly over time.  It is possible that this
-extension wil be removed in future versions of G++.
+extension will be removed in future versions of G++.
 
 A using-directive with @code{__attribute ((strong))} is stronger
 than a normal using-directive in two ways:
 
 @itemize @bullet
 @item
-Templates from the used namespace can be specialized as though they were members of the using namespace.
+Templates from the used namespace can be specialized and explicitly
+instantiated as though they were members of the using namespace.
 
 @item
 The using namespace is considered an associated namespace of all
@@ -10425,6 +10426,9 @@ templates in the used namespace for purposes of argument-dependent
 name lookup.
 @end itemize
 
+The used namespace must be nested within the using namespace so that
+normal unqualified lookup works properly.
+
 This is useful for composing a namespace transparently from
 implementation namespaces.  For example: