Patch for g++-980308: Problems with template template parameters
Kriang Lerdsuwanakij
lerdsuwa@scf-fs.usc.edu
Tue Mar 10 20:25:00 GMT 1998
Bernd Nottelmann (nottelm@ptp283.uni-muenster.de) wrote
> I have already reported this compiler error a few weeks ago,
> but noone has responded. :-(
> The following code causes an internal compiler error:
(code snipped)
Hi
Thanks. Here is a patch that fix your bug. Note that, in your code,
'this' has to be changed to '*this' to make the argument match your
constructor declaration.
--Kriang
* lex.c (do_identifier): Handle TEMPLATE_DECL that was
added in the class scope to catch redefinition error.
diff -cprN gcc-old/cp/lex.c gcc/cp/lex.c
*** gcc-old/cp/lex.c Tue Mar 10 19:10:16 1998
--- gcc/cp/lex.c Tue Mar 10 19:08:11 1998
*************** do_identifier (token, parsing)
*** 2811,2817 ****
But we still want to return this value. */
id = lookup_field (current_class_type, token, 0, 0);
else if (TREE_CODE (field) == VAR_DECL
! || TREE_CODE (field) == CONST_DECL)
id = field;
else if (TREE_CODE (field) != FIELD_DECL)
my_friendly_abort (61);
--- 2811,2818 ----
But we still want to return this value. */
id = lookup_field (current_class_type, token, 0, 0);
else if (TREE_CODE (field) == VAR_DECL
! || TREE_CODE (field) == CONST_DECL
! || TREE_CODE (field) == TEMPLATE_DECL)
id = field;
else if (TREE_CODE (field) != FIELD_DECL)
my_friendly_abort (61);
diff -cprN gcc-old/testsuite/g++.old-deja/g++.pt/ttp43.C
gcc/testsuite/g++.old-deja/g++.pt/ttp43.C
*** gcc-old/testsuite/g++.old-deja/g++.pt/ttp43.C Wed Dec 31 16:00:00
1969
--- gcc/testsuite/g++.old-deja/g++.pt/ttp43.C Tue Mar 10 19:09:10 1998
***************
*** 0 ****
--- 1,28 ----
+ template < class T, template <class> class E1, template <class> class
E2 >
+ struct Add {
+ Add(const E1<T>& e1, const E2<T>& e2) {}
+ };
+
+
+ template < class T, template <class> class E1, template <class> class
E2 >
+ struct Mul {
+ Mul(const E1<T>& e1, const E2<T>& e2) {}
+ };
+
+
+ template < class T >
+ struct Lit {
+ Lit(const T& t) {}
+ };
+
+
+ template < class T >
+ struct Id {
+ Add < T, Id, Lit > operator+(const T& t) const {
+ return Add < T, Id, Lit >(*this, Lit<T>(t));
+ }
+
+ Mul < T, Id, Lit > operator*(const T& t) const {
+ return Mul < T, Id, Lit >(*this, Lit<T>(t));
+ }
+ };
More information about the Gcc-bugs
mailing list