This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Patch for g++-980308: Problems with template template parameters


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));
+   }
+ };


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]