pt.c (tsubst_decl): Set DECL_CONTEXT for namespace-scope variables.
authorMark Mitchell <mark@codesourcery.com>
Wed, 11 Jul 2001 06:24:57 +0000 (06:24 +0000)
committerMark Mitchell <mmitchel@gcc.gnu.org>
Wed, 11 Jul 2001 06:24:57 +0000 (06:24 +0000)
* pt.c (tsubst_decl): Set DECL_CONTEXT for namespace-scope
variables.

From-SVN: r43924

gcc/cp/ChangeLog
gcc/cp/pt.c
gcc/testsuite/g++.old-deja/g++.ns/template18.C [new file with mode: 0644]

index 7473cab405a176d259da9161bdf7c009dfc74156..d7a843f8ad5eee45c1924377a9097fcfeb80806c 100644 (file)
@@ -1,3 +1,8 @@
+2001-07-10  Mark Mitchell  <mark@codesourcery.com>
+
+       * pt.c (tsubst_decl): Set DECL_CONTEXT for namespace-scope
+       variables.
+
 2001-07-10  Jason Merrill  <jason_merrill@redhat.com>
 
        * semantics.c (cp_expand_stmt): Fix for null
index b6016402e16ffb361a51bba26b70c1db3378b280..3d6279a82823dd81224999c839c7ce80130b896c 100644 (file)
@@ -5946,12 +5946,13 @@ tsubst_decl (t, args, type)
          ctx = tsubst_aggr_type (DECL_CONTEXT (t), args, 
                                  /*complain=*/1,
                                  in_decl, /*entering_scope=*/1);
+       else if (DECL_NAMESPACE_SCOPE_P (t))
+         ctx = DECL_CONTEXT (t);
        else
          {
            /* Subsequent calls to pushdecl will fill this in.  */
            ctx = NULL_TREE;
-           if (!DECL_NAMESPACE_SCOPE_P (t))
-             local_p = 1;
+           local_p = 1;
          }
 
        /* Check to see if we already have this specialization.  */
diff --git a/gcc/testsuite/g++.old-deja/g++.ns/template18.C b/gcc/testsuite/g++.old-deja/g++.ns/template18.C
new file mode 100644 (file)
index 0000000..4b3f720
--- /dev/null
@@ -0,0 +1,24 @@
+// Build don't run:
+// Origin: Andrey Slepuhin <pooh@msu.ru>
+
+namespace A
+{
+  int j;
+
+  template <typename val_t>
+  struct X
+  {
+    inline X ()
+    {
+      extern int j;
+      i = j;
+    }
+
+    int i;
+  };
+}
+
+int main ()
+{
+  A::X<int> x;
+}