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: PR 15165


This patch fixes PR 15165, a case where we tried to do a template
instantiation, figured out it didn't work, and then blew up -- rather
than simply ignoring the instantiation as required.

--
Mark Mitchell
CodeSourcery, LLC
mark@codesourcery.com

2004-05-23  Mark Mitchell  <mark@codesourcery.com>

	PR c++/15165
	* pt.c (instantiate_template): Robustify.

2004-05-23  Mark Mitchell  <mark@codesourcery.com>

	PR c++/15165
	* g++.dg/template/crash19.C: New test.

Index: cp/pt.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/pt.c,v
retrieving revision 1.816.2.25
diff -c -5 -p -r1.816.2.25 pt.c
*** cp/pt.c	22 May 2004 21:43:57 -0000	1.816.2.25
--- cp/pt.c	23 May 2004 22:42:30 -0000
*************** instantiate_template (tree tmpl, tree ta
*** 8652,8665 ****
    my_friendly_assert (TREE_CODE (tmpl) == TEMPLATE_DECL, 283);
  
    /* If this function is a clone, handle it specially.  */
    if (DECL_CLONED_FUNCTION_P (tmpl))
      {
!       tree spec = instantiate_template (DECL_CLONED_FUNCTION (tmpl), targ_ptr,
! 					complain);
        tree clone;
        
        /* Look for the clone.  */
        for (clone = TREE_CHAIN (spec);
  	   clone && DECL_CLONED_FUNCTION_P (clone);
  	   clone = TREE_CHAIN (clone))
  	if (DECL_NAME (clone) == DECL_NAME (tmpl))
--- 8652,8669 ----
    my_friendly_assert (TREE_CODE (tmpl) == TEMPLATE_DECL, 283);
  
    /* If this function is a clone, handle it specially.  */
    if (DECL_CLONED_FUNCTION_P (tmpl))
      {
!       tree spec;
        tree clone;
        
+       spec = instantiate_template (DECL_CLONED_FUNCTION (tmpl), targ_ptr,
+ 				   complain);
+       if (spec == error_mark_node)
+ 	return error_mark_node;
+ 
        /* Look for the clone.  */
        for (clone = TREE_CHAIN (spec);
  	   clone && DECL_CLONED_FUNCTION_P (clone);
  	   clone = TREE_CHAIN (clone))
  	if (DECL_NAME (clone) == DECL_NAME (tmpl))
Index: testsuite/g++.dg/template/crash19.C
===================================================================
RCS file: testsuite/g++.dg/template/crash19.C
diff -N testsuite/g++.dg/template/crash19.C
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- testsuite/g++.dg/template/crash19.C	23 May 2004 22:42:31 -0000
***************
*** 0 ****
--- 1,17 ----
+ // PR c++/15165
+ 
+ struct S 
+ { 
+     template <class T> S(const T &e);
+ };
+ int operator *(const double, const S &); 
+ template <class T>
+ struct X { 
+     enum { SIXTY_FOUR=64 }; 
+     struct node {
+       unsigned char *ptr[sizeof(T)*SIXTY_FOUR];
+         void d() {}
+     };
+     node *head; 
+ };
+ template struct X<int>;


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