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 3.3/3.4] Fix PR7939 regression


Hi

This obvious patch fixes an ICE reported as PR7939 (a regression
on both 3.3 and 3.4).  The ICE is simply due to the argument 't1' 
in comptypes being an error_mark_node after template substitution.
I think the different behavior for 't1' and 't2' (even when 'strict'
is COMPARE_STRICT) make comptypes prone to error.

Tested on i686-pc-linux-gnu.  Committed to main trunk as obvious.
Is this OK for 3.3 branch?

--Kriang


2003-09-16  Kriang Lerdsuwanakij  <lerdsuwa@users.sourceforge.net>

	PR c++/7939
	* typeck.c (comptypes): Don't ICE when its first argument is
	error_mark_node.
	(compparms): Reverse the arguments of same_type_p.

2003-09-16  Kriang Lerdsuwanakij  <lerdsuwa@users.sourceforge.net>

	PR c++/7939
	* g++.dg/template/crash11.C: New test.


diff -cprN gcc-main-save/gcc/cp/typeck.c gcc-main-new/gcc/cp/typeck.c
*** gcc-main-save/gcc/cp/typeck.c	Tue Sep  2 21:48:37 2003
--- gcc-main-new/gcc/cp/typeck.c	Mon Sep 15 22:25:07 2003
*************** comptypes (tree t1, tree t2, int strict)
*** 900,910 ****
    if (t1 == t2)
      return true;
  
-   /* This should never happen.  */
-   my_friendly_assert (t1 != error_mark_node, 307);
- 
    /* Suppress errors caused by previously reported errors */
!   if (t2 == error_mark_node)
      return false;
    
    my_friendly_assert (TYPE_P (t1) && TYPE_P (t2), 20030623);
--- 900,907 ----
    if (t1 == t2)
      return true;
  
    /* Suppress errors caused by previously reported errors */
!   if (t1 == error_mark_node || t2 == error_mark_node)
      return false;
    
    my_friendly_assert (TYPE_P (t1) && TYPE_P (t2), 20030623);
*************** compparms (tree parms1, tree parms2)
*** 1170,1176 ****
  	 they fail to match.  */
        if (!t1 || !t2)
  	return false;
!       if (!same_type_p (TREE_VALUE (t2), TREE_VALUE (t1)))
  	return false;
      }
    return true;
--- 1167,1173 ----
  	 they fail to match.  */
        if (!t1 || !t2)
  	return false;
!       if (!same_type_p (TREE_VALUE (t1), TREE_VALUE (t2)))
  	return false;
      }
    return true;
diff -cprN gcc-main-save/gcc/testsuite/g++.dg/template/crash11.C gcc-main-new/gcc/testsuite/g++.dg/template/crash11.C
*** gcc-main-save/gcc/testsuite/g++.dg/template/crash11.C	Thu Jan  1 07:00:00 1970
--- gcc-main-new/gcc/testsuite/g++.dg/template/crash11.C	Tue Sep 16 20:54:41 2003
***************
*** 0 ****
--- 1,9 ----
+ // { dg-do compile }
+ 
+ // Origin: kparz@iastate.edu
+ 
+ // PR c++/7939: ICE for invalid function parameter after template
+ // substitution.
+ 
+ template <class T, class U> void foo(T, U) {}
+ template <class T> void foo<T,void>(T, void) {} // { dg-error "incomplete|invalid|partial" }


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