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++/37439


Oops, once we've seen the function body the parms have DECL_CONTEXT set. Which is fine, we just shouldn't assert otherwise.

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

	PR c++/37439
	* pt.c (tsubst_copy) [PARM_DECL]: Don't abort if the parm has
	DECL_CONTEXT set.

Index: cp/pt.c
===================================================================
*** cp/pt.c	(revision 140120)
--- cp/pt.c	(working copy)
*************** tsubst_copy (tree t, tree args, tsubst_f
*** 9809,9815 ****
  	     Replace it with an arbitrary expression with the same type
  	     (*(T*)0).  This should only occur in an unevaluated context
  	     (i.e. decltype).  */
! 	  gcc_assert (skip_evaluation && DECL_CONTEXT (t) == NULL_TREE);
  	  r = non_reference (TREE_TYPE (t));
  	  r = tsubst (r, args, complain, in_decl);
  	  r = build_pointer_type (r);
--- 9809,9815 ----
  	     Replace it with an arbitrary expression with the same type
  	     (*(T*)0).  This should only occur in an unevaluated context
  	     (i.e. decltype).  */
! 	  gcc_assert (skip_evaluation);
  	  r = non_reference (TREE_TYPE (t));
  	  r = tsubst (r, args, complain, in_decl);
  	  r = build_pointer_type (r);
Index: testsuite/g++.dg/cpp0x/auto6.C
===================================================================
*** testsuite/g++.dg/cpp0x/auto6.C	(revision 140120)
--- testsuite/g++.dg/cpp0x/auto6.C	(working copy)
*************** auto f() -> int
*** 6,12 ****
  }
  
  template<class T, class U>
! auto add(T t, U u) -> decltype (t+u);
  
  template<class T, class U>
  decltype(T()+U()) add2(T t, U u);
--- 6,15 ----
  }
  
  template<class T, class U>
! auto add(T t, U u) -> decltype (t+u)
! {
!   return t+u;
! }
  
  template<class T, class U>
  decltype(T()+U()) add2(T t, U u);

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