This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
C++ PATCH: Fix PR2626
- To: gcc-patches at gcc dot gnu dot org
- Subject: C++ PATCH: Fix PR2626
- From: Mark Mitchell <mark at codesourcery dot com>
- Date: Tue, 10 Jul 2001 23:05:58 -0700
- Organization: CodeSourcery, LLC
This patch fixes PR2626, a regression from GCC 2.95.x.
Tested on i686-pc-linux-gnu, applied to the branch and the trunk.
--
Mark Mitchell mark@codesourcery.com
CodeSourcery, LLC http://www.codesourcery.com
2001-07-10 Mark Mitchell <mark@codesourcery.com>
* pt.c (tsubst_decl): Set DECL_CONTEXT for namespace-scope
variables.
Index: cp/pt.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/pt.c,v
retrieving revision 1.516.2.15
diff -c -p -r1.516.2.15 pt.c
*** pt.c 2001/06/18 10:35:29 1.516.2.15
--- pt.c 2001/07/11 05:19:19
*************** tsubst_decl (t, args, type)
*** 5959,5970 ****
ctx = tsubst_aggr_type (DECL_CONTEXT (t), args,
/*complain=*/1,
in_decl, /*entering_scope=*/1);
else
{
/* Subsequent calls to pushdecl will fill this in. */
ctx = NULL_TREE;
! if (!DECL_NAMESPACE_SCOPE_P (t))
! local_p = 1;
}
/* Check to see if we already have this specialization. */
--- 5959,5971 ----
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;
! local_p = 1;
}
/* Check to see if we already have this specialization. */
Index: testsuite/g++.old-deja/g++.ns/template18.C
===================================================================
RCS file: template18.C
diff -N template18.C
*** /dev/null Tue May 5 13:32:27 1998
--- template18.C Tue Jul 10 22:19:23 2001
***************
*** 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;
+ }