From 2ba9c47ebd2de5826889bee5542029e69c7adc01 Mon Sep 17 00:00:00 2001 From: Mark Mitchell Date: Wed, 11 Jul 2001 06:24:57 +0000 Subject: [PATCH] pt.c (tsubst_decl): Set DECL_CONTEXT for namespace-scope variables. * pt.c (tsubst_decl): Set DECL_CONTEXT for namespace-scope variables. From-SVN: r43924 --- gcc/cp/ChangeLog | 5 ++++ gcc/cp/pt.c | 5 ++-- .../g++.old-deja/g++.ns/template18.C | 24 +++++++++++++++++++ 3 files changed, 32 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/g++.old-deja/g++.ns/template18.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 7473cab405a..d7a843f8ad5 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2001-07-10 Mark Mitchell + + * pt.c (tsubst_decl): Set DECL_CONTEXT for namespace-scope + variables. + 2001-07-10 Jason Merrill * semantics.c (cp_expand_stmt): Fix for null diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index b6016402e16..3d6279a8282 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -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 index 00000000000..4b3f720e74b --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.ns/template18.C @@ -0,0 +1,24 @@ +// Build don't run: +// Origin: Andrey Slepuhin + +namespace A +{ + int j; + + template + struct X + { + inline X () + { + extern int j; + i = j; + } + + int i; + }; +} + +int main () +{ + A::X x; +}