This is the mail archive of the gcc-patches@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]
Other format: [Raw text]

C++ PATCH for c++/28743


Pretty simple patch, just changes an abort into an error since the situation we were asserting against can occur with invalid code.

Tested x86_64-pc-linux-gnu, applied to trunk.
2008-11-25  Jason Merrill  <jason@redhat.com>

	PR c++/28743
	* decl2.c (check_classfn): Error rather than abort on parameter
	list mismatch.
	* g++.dg/template/nontype18.C: New test.

Index: cp/decl2.c
===================================================================
*** cp/decl2.c	(revision 142211)
--- cp/decl2.c	(working copy)
*************** check_classfn (tree ctype, tree function
*** 572,580 ****
       either were not passed, or they are the same of DECL_TEMPLATE_PARMS.  */
    if (TREE_CODE (function) == TEMPLATE_DECL)
      {
!       gcc_assert (!template_parms
! 		  || comp_template_parms (template_parms,
! 					  DECL_TEMPLATE_PARMS (function)));
        template_parms = DECL_TEMPLATE_PARMS (function);
      }
  
--- 572,585 ----
       either were not passed, or they are the same of DECL_TEMPLATE_PARMS.  */
    if (TREE_CODE (function) == TEMPLATE_DECL)
      {
!       if (template_parms
! 	  && !comp_template_parms (template_parms,
! 				   DECL_TEMPLATE_PARMS (function)))
! 	{
! 	  error ("template parameter lists provided don't match the "
! 		 "template parameters of %qD", function);
! 	  return error_mark_node;
! 	}
        template_parms = DECL_TEMPLATE_PARMS (function);
      }
  
Index: testsuite/g++.dg/template/nontype18.C
===================================================================
*** testsuite/g++.dg/template/nontype18.C	(revision 0)
--- testsuite/g++.dg/template/nontype18.C	(revision 0)
***************
*** 0 ****
--- 1,8 ----
+ // PR c++/28743
+ 
+ template<int I> struct A
+ {
+     template<typename T> void foo();
+ };
+ 
+ template<int I> template<typename T> void A<0>::foo() {} // { dg-error "template parameter" }

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