re PR c++/16021 (Tests for container swap specialisations FAIL in debug mode)
authorJason Merrill <jason@redhat.com>
Thu, 26 Jan 2006 22:29:12 +0000 (17:29 -0500)
committerJason Merrill <jason@gcc.gnu.org>
Thu, 26 Jan 2006 22:29:12 +0000 (17:29 -0500)
        PR c++/16021
        * name-lookup.c (parse_using_directive): Require strong using to
        name a nested namespace.

From-SVN: r110282

gcc/cp/ChangeLog
gcc/cp/name-lookup.c
gcc/testsuite/g++.dg/lookup/strong-using-1.C
gcc/testsuite/g++.dg/lookup/strong-using-2.C
gcc/testsuite/g++.dg/lookup/strong-using-3.C

index 9dea52e097bde82aa55f43d103cf4d5bfbf54501..741d3de0a0e07651c9ce51df81c9d4cb7f014482 100644 (file)
@@ -1,3 +1,9 @@
+2006-01-26  Jason Merrill  <jason@redhat.com>
+
+       PR c++/16021
+       * name-lookup.c (parse_using_directive): Require strong using to
+       name a nested namespace.
+
 2006-01-25  Volker Reichelt  <reichelt@igpm.rwth-aachen.de>
 
        Revert:
index e0ee7a2a4e1b1848c3708e1da2f853ffbcf9b3d5..2f33b096d4e063ea06d77d8208a712e978e231f8 100644 (file)
@@ -3295,9 +3295,14 @@ parse_using_directive (tree namespace, tree attribs)
          if (!toplevel_bindings_p ())
            error ("strong using only meaningful at namespace scope");
          else if (namespace != error_mark_node)
-           DECL_NAMESPACE_ASSOCIATIONS (namespace)
-             = tree_cons (current_namespace, 0,
-                          DECL_NAMESPACE_ASSOCIATIONS (namespace));
+           {
+             if (!is_ancestor (current_namespace, namespace))
+               error ("current namespace %qD does not enclose strongly used namespace %qD",
+                      current_namespace, namespace);
+             DECL_NAMESPACE_ASSOCIATIONS (namespace)
+               = tree_cons (current_namespace, 0,
+                            DECL_NAMESPACE_ASSOCIATIONS (namespace));
+           }
        }
       else
        warning (OPT_Wattributes, "%qD attribute directive ignored", name);
index 3d63f25b8b2c58c81c3d3cf56025f7b142841951..a16fd6a50b973b81e50dbec175309326322e5a6b 100644 (file)
@@ -2,10 +2,10 @@
 
 // { dg-do compile }
 
-namespace foo {
-  template <class T> void swap(T, T);
-}
 namespace fool {
+  namespace foo {
+    template <class T> void swap(T, T);
+  }
   using namespace foo __attribute__((strong));
   template <class T> void swap(T);
 }
index f8b5f64fbd24d9c941db2e465d6723e9ce9a6758..21e47cba014b39dffc9353eede793106f40c3304 100644 (file)
@@ -2,16 +2,16 @@
 
 // { dg-do compile }
 
-namespace foo_impl {
-  class T; // { dg-error "T" "" }
-}
-namespace bar_impl {
-  class T; // { dg-error "T" "" }
-}
 namespace foo {
+  namespace foo_impl {
+    class T; // { dg-error "T" "" }
+  }
   using namespace foo_impl __attribute__((strong));
 }
 namespace bar {
+  namespace bar_impl {
+    class T; // { dg-error "T" "" }
+  }
   using namespace bar_impl __attribute__((strong));
   using namespace foo;
 }
index 2ea538e3b1fccb040e19abe3e2b34a445dd38005..9b4d3c3ffea0695313f1e9298280a897370c8367 100644 (file)
@@ -2,10 +2,10 @@
 
 // { dg-do compile }
 
-namespace foo {
-  template <class T> void f(T, T);
-}
 namespace bar {
+  namespace foo {
+    template <class T> void f(T, T);
+  }
   using namespace foo __attribute__((strong));
   template <class T> void f(T);
 }