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]

Re: C++ PATCH: PR 16716, 17327


Mark Mitchell wrote:
  /* Note that DECL can be defined in this translation unit, if
--- 10135,10145 ----
  	      && !template_args_equal (parm, arg))
  	    return 1;
  	  else
  	    return 0;
  	}
!       gcc_unreachable ();
        return 1;
      }
this is not right. you shouldn't have live code after a gcc_unreachable,
plus if you look further back, you'll see this is the equivalent of
	if (cond) {do something & return;}
	gcc_unreachable ();

which should be written simply as
	gcc_assert (cond)
	do something and return;

I've installed this patch to do just that.

tested on i686-pc-linux-gnu.

nathan

--
Nathan Sidwell    ::   http://www.codesourcery.com   ::     CodeSourcery LLC
nathan@codesourcery.com    ::     http://www.planetfall.pwp.blueyonder.co.uk

2004-09-14  Nathan Sidwell  <nathan@codesourcery.com>

	* pt.c (unify): Replace gcc_unreachable with gcc_assert.

Index: cp/pt.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/pt.c,v
retrieving revision 1.922
diff -c -3 -p -r1.922 pt.c
*** cp/pt.c	14 Sep 2004 00:29:02 -0000	1.922
--- cp/pt.c	14 Sep 2004 07:36:06 -0000
*************** unify (tree tparms, tree targs, tree par
*** 10109,10144 ****
        return 1;
  
      default:
!       if (IS_EXPR_CODE_CLASS (TREE_CODE_CLASS (TREE_CODE (parm))))
! 	{
! 
! 	  /* We're looking at an expression.  This can happen with
! 	     something like: 
  	   
! 	       template <int I>
! 	       void foo(S<I>, S<I + 2>);
  
! 	     This is a "nondeduced context":
  
! 	       [deduct.type]
  	   
! 	       The nondeduced contexts are:
  
! 	       --A type that is a template-id in which one or more of
! 	         the template-arguments is an expression that references
! 	         a template-parameter.  
! 
! 	     In these cases, we assume deduction succeeded, but don't
! 	     actually infer any unifications.  */
! 
! 	  if (!uses_template_parms (parm)
! 	      && !template_args_equal (parm, arg))
! 	    return 1;
! 	  else
! 	    return 0;
! 	}
!       gcc_unreachable ();
!       return 1;
      }
  }
  
--- 10109,10140 ----
        return 1;
  
      default:
!       gcc_assert (IS_EXPR_CODE_CLASS (TREE_CODE_CLASS (TREE_CODE (parm))));
!       
!       /* We must be looking at an expression.  This can happen with
! 	 something like: 
  	   
! 	   template <int I>
! 	   void foo(S<I>, S<I + 2>);
  
! 	 This is a "nondeduced context":
  
! 	   [deduct.type]
  	   
! 	   The nondeduced contexts are:
  
! 	   --A type that is a template-id in which one or more of
! 	     the template-arguments is an expression that references
! 	     a template-parameter.  
! 
! 	 In these cases, we assume deduction succeeded, but don't
! 	 actually infer any unifications.  */
! 
!       if (!uses_template_parms (parm)
! 	  && !template_args_equal (parm, arg))
! 	return 1;
!       else
! 	return 0;
      }
  }
  

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