C++ PATCH for template namespace crash
Alex Samuel
samuel@codesourcery.com
Sun Aug 29 21:04:00 GMT 1999
Here's a fix for the bug originally reported by deb@pixar.com (David
Baraff) on Tue, 4 May 99 22:00 PDT.
Alex Samuel
CodeSourcery, LLC
1999-08-29 Alex Samuel <samuel@codesourcery.com>
* pt.c (push_template_decl_real): Use template declaration from
class type if it exists.
Index: template13.C
===================================================================
RCS file: /cvs/egcs/egcs/gcc/testsuite/g++.old-deja/g++.ns/template13.C,v
retrieving revision 1.3
diff -c -r1.3 template13.C
*** template13.C 1999/08/11 19:24:29 1.3
--- template13.C 1999/08/30 04:01:00
***************
*** 4,10 ****
{
template<class T>
void foo(); // trick it to provide some prior declaration
! template<class T>class X;
}
template <typename T>
--- 4,10 ----
{
template<class T>
void foo(); // trick it to provide some prior declaration
! template<class T>class X; // ERROR - previous declaration
}
template <typename T>
***************
*** 19,22 ****
}
template<class T,class U>
! class bar::X{}; // ERROR - does not match declaration - XFAIL *-*-*
--- 19,22 ----
}
template<class T,class U>
! class bar::X{}; // ERROR - does not match declaration
*** /dev/null Tue May 5 13:32:27 1998
--- template14.C Sun Aug 29 20:38:59 1999
***************
*** 0 ****
--- 1,14 ----
+ // Build don't link:
+ // Origin: Alex Samuel <samuel@codesourcery.com>
+
+ namespace Outer
+ {
+ template <class T> class Inner;
+ }
+
+ template <class T>
+ class Outer::Inner
+ {
+ public:
+ Inner ();
+ };
Index: pt.c
===================================================================
RCS file: /cvs/egcs/egcs/gcc/cp/pt.c,v
retrieving revision 1.341
diff -c -r1.341 pt.c
*** pt.c 1999/08/27 06:07:06 1.341
--- pt.c 1999/08/30 03:59:00
***************
*** 2461,2466 ****
--- 2461,2482 ----
&& DECL_TEMPLATE_INFO (decl)
&& DECL_TI_TEMPLATE (decl))
tmpl = DECL_TI_TEMPLATE (decl);
+ /* If DECL is a TYPE_DECL for a class-template, then there won't
+ be DECL_LANG_SPECIFIC. The information equivalent to
+ DECL_TEMPLATE_INFO is found in TYPE_TEMPLATE_INFO instead. */
+ else if (DECL_IMPLICIT_TYPEDEF_P (decl)
+ && TYPE_TEMPLATE_INFO (TREE_TYPE (decl))
+ && TYPE_TI_TEMPLATE (TREE_TYPE (decl)))
+ {
+ /* Since a template declaration already existed for this
+ class-type, we must be redeclaring it here. Make sure
+ that the redeclaration is legal. */
+ redeclare_class_template (TREE_TYPE (decl),
+ current_template_parms);
+ /* We don't need to create a new TEMPLATE_DECL; just use the
+ one we already had. */
+ tmpl = TYPE_TI_TEMPLATE (TREE_TYPE (decl));
+ }
else
{
tmpl = build_template_decl (decl, current_template_parms);
More information about the Gcc-patches
mailing list