Patchwork [C++] Use TYPE_PTR_P and VOID_TYPE_P more often

login
register
mail settings
Submitter Paolo Carlini
Date March 29, 2013, 7:28 p.m.
Message ID <5155EB53.4080706@oracle.com>
Download mbox | patch
Permalink /patch/232487/
State New
Headers show

Comments

Paolo Carlini - March 29, 2013, 7:28 p.m.
Hi,

thus, as mentioned in the exchange with Gaby, I took care of this clean-up.

Two relatively interesting bits:
- In cp_build_function_call_vec I simplified a tad the code with 
TYPE_PTRFN_P.
- In convert_force we had a curious duplicate:

     && TREE_CODE (TREE_TYPE (e)) == POINTER_TYPE

Booted and tested x86_64-linux. Ok?

Thanks,
Paolo.

///////////////////
2013-03-29

	* call.c (add_builtin_candidate): Use TYPE_PTR_P and VOID_TYPE_P.
	(build_op_call_1): Likewise.
	(build_over_call): Likewise.
	(compare_ics): Likewise.
	* class.c (build_base_path): Likewise.
	(resolve_address_of_overloaded_function): Likewise.
	* cp-tree.h: Likewise.
	* cvt.c (cp_convert_to_pointer): Likewise.
	(convert_to_reference): Likewise.
	(ocp_convert): Likewise.
	(convert_force): Likewise, tidy.
	* cxx-pretty-print.c (pp_cxx_postfix_expression): Likewise.
	(pp_cxx_ptr_operator): Likewise.
	* decl.c (duplicate_decls): Likewise.
	(start_decl): Likewise.
	(grok_op_properties): Likewise.
	(start_preparsed_function): Likewise.
	(store_parm_decls): Likewise.
	(finish_function): Likewise.
	* decl2.c (delete_sanity): Likewise.
	(acceptable_java_type): Likewise.
	(grokbitfield): Likewise.
	(cp_reconstruct_complex_type): Likewise.
	* error.c (dump_type_prefix): Likewise.
	(dump_expr): Likewise.
	* except.c (push_eh_cleanup): Likewise.
	(complete_ptr_ref_or_void_ptr_p): Likewise.
	(can_convert_eh): Likewise.
	* init.c (build_new_1): Likewise.
	(build_delete): Likewise.
	(build_vec_delete): Likewise.
	* mangle.c (write_type): Likewise.
	* parser.c (lookup_literal_operator): Likewise.
	* pt.c (convert_nontype_argument_function): Likewise.
	(convert_nontype_argument): Likewise.
	(tsubst): Likewise.
	(unify): Likewise.
	(dependent_type_p_r): Likewise.
	* rtti.c (build_headof): Likewise.
	(build_typeid): Likewise.
	(build_dynamic_cast_1): Likewise.
	(target_incomplete_p): Likewise.
	(typeinfo_in_lib_p): Likewise.
	* semantics.c (finish_omp_for): Likewise.
	(cxx_eval_call_expression): Likewise.
	(maybe_resolve_dummy): Likewise.
	* tree.c (build_target_expr): Likewise.
	(cp_build_qualified_type_real): Likewise.
	* typeck.c (composite_pointer_type_r): Likewise.
	(composite_pointer_type): Likewise.
	(comp_except_types): Likewise.
	(cxx_sizeof_nowarn): Likewise.
	(string_conv_p): Likewise.
	(cp_build_array_ref): Likewise.
	(cp_build_function_call_vec): Likewise, also use TYPE_PTRFN_P.
	(pointer_diff): Likewise.
	(cp_build_addr_expr_1): Likewise.
	(cp_build_unary_op): Likewise.
	(build_static_cast_1): Likewise.
	(cp_build_c_cast): Likewise.
	(comp_ptr_ttypes_real): Likewise.
	(ptr_reasonably_similar): Likewise.
	(comp_ptr_ttypes_const): Likewise.
	(casts_away_constness): Likewise.
	(check_literal_operator_args): Likewise.
	* typeck2.c (build_x_arrow): Likewise.
	(add_exception_specifier): Likewise.
Jason Merrill - March 29, 2013, 8:03 p.m.
OK.

Jason

Patch

Index: call.c
===================================================================
--- call.c	(revision 197242)
+++ call.c	(working copy)
@@ -2285,7 +2285,7 @@  add_builtin_candidate (struct z_candidate **candid
 	     T&      operator*(T*);  */
 
     case INDIRECT_REF:
-      if (TREE_CODE (type1) == POINTER_TYPE
+      if (TYPE_PTR_P (type1)
 	  && !uses_template_parms (TREE_TYPE (type1))
 	  && (TYPE_PTROB_P (type1)
 	      || TREE_CODE (TREE_TYPE (type1)) == FUNCTION_TYPE))
@@ -2301,7 +2301,7 @@  add_builtin_candidate (struct z_candidate **candid
 	     T       operator-(T);  */
 
     case UNARY_PLUS_EXPR: /* unary + */
-      if (TREE_CODE (type1) == POINTER_TYPE)
+      if (TYPE_PTR_P (type1))
 	break;
     case NEGATE_EXPR:
       if (ARITHMETIC_TYPE_P (type1))
@@ -2325,8 +2325,7 @@  add_builtin_candidate (struct z_candidate **candid
      where CV12 is the union of CV1 and CV2.  */
 
     case MEMBER_REF:
-      if (TREE_CODE (type1) == POINTER_TYPE
-	  && TYPE_PTRMEM_P (type2))
+      if (TYPE_PTR_P (type1) && TYPE_PTRMEM_P (type2))
 	{
 	  tree c1 = TREE_TYPE (type1);
 	  tree c2 = TYPE_PTRMEM_CLASS_TYPE (type2);
@@ -2546,7 +2545,7 @@  add_builtin_candidate (struct z_candidate **candid
 	      || (TYPE_PTR_P (type1) && TYPE_PTR_P (type2))
 	      || (TYPE_PTRDATAMEM_P (type1) && TYPE_PTRDATAMEM_P (type2))
 	      || ((TYPE_PTRMEMFUNC_P (type1)
-		   || TREE_CODE (type1) == POINTER_TYPE)
+		   || TYPE_PTR_P (type1))
 		  && null_ptr_cst_p (args[1])))
 	    {
 	      type2 = type1;
@@ -4083,12 +4082,12 @@  build_op_call_1 (tree obj, vec<tree, va_gc> **args
       tree fns = TREE_VALUE (convs);
       tree totype = TREE_TYPE (convs);
 
-      if ((TREE_CODE (totype) == POINTER_TYPE
+      if ((TYPE_PTR_P (totype)
 	   && TREE_CODE (TREE_TYPE (totype)) == FUNCTION_TYPE)
 	  || (TREE_CODE (totype) == REFERENCE_TYPE
 	      && TREE_CODE (TREE_TYPE (totype)) == FUNCTION_TYPE)
 	  || (TREE_CODE (totype) == REFERENCE_TYPE
-	      && TREE_CODE (TREE_TYPE (totype)) == POINTER_TYPE
+	      && TYPE_PTR_P (TREE_TYPE (totype))
 	      && TREE_CODE (TREE_TYPE (TREE_TYPE (totype))) == FUNCTION_TYPE))
 	for (; fns; fns = OVL_NEXT (fns))
 	  {
@@ -6764,7 +6763,7 @@  build_over_call (struct z_candidate *cand, int fla
 
 	 So we can assume that anything passed as 'this' is non-null, and
 	 optimize accordingly.  */
-      gcc_assert (TREE_CODE (parmtype) == POINTER_TYPE);
+      gcc_assert (TYPE_PTR_P (parmtype));
       /* Convert to the base in which the function was declared.  */
       gcc_assert (cand->conversion_path != NULL_TREE);
       converted_arg = build_base_path (PLUS_EXPR,
@@ -8134,8 +8133,8 @@  compare_ics (conversion *ics1, conversion *ics2)
 	   conversion of B* to A* is better than conversion of B* to
 	   void*, and conversion of A* to void* is better than
 	   conversion of B* to void*.  */
-      if (TREE_CODE (deref_to_type1) == VOID_TYPE
-	  && TREE_CODE (deref_to_type2) == VOID_TYPE)
+      if (VOID_TYPE_P (deref_to_type1)
+	  && VOID_TYPE_P (deref_to_type2))
 	{
 	  if (is_properly_derived_from (deref_from_type1,
 					deref_from_type2))
@@ -8144,12 +8143,12 @@  compare_ics (conversion *ics1, conversion *ics2)
 					     deref_from_type1))
 	    return 1;
 	}
-      else if (TREE_CODE (deref_to_type1) == VOID_TYPE
-	       || TREE_CODE (deref_to_type2) == VOID_TYPE)
+      else if (VOID_TYPE_P (deref_to_type1)
+	       || VOID_TYPE_P (deref_to_type2))
 	{
 	  if (same_type_p (deref_from_type1, deref_from_type2))
 	    {
-	      if (TREE_CODE (deref_to_type2) == VOID_TYPE)
+	      if (VOID_TYPE_P (deref_to_type2))
 		{
 		  if (is_properly_derived_from (deref_from_type1,
 						deref_to_type1))
Index: class.c
===================================================================
--- class.c	(revision 197242)
+++ class.c	(working copy)
@@ -244,7 +244,7 @@  build_base_path (enum tree_code code,
   tree null_test = NULL;
   tree ptr_target_type;
   int fixed_type_p;
-  int want_pointer = TREE_CODE (TREE_TYPE (expr)) == POINTER_TYPE;
+  int want_pointer = TYPE_PTR_P (TREE_TYPE (expr));
   bool has_empty = false;
   bool virtual_access;
 
@@ -7142,7 +7142,7 @@  resolve_address_of_overloaded_function (tree targe
   /* By the time we get here, we should be seeing only real
      pointer-to-member types, not the internal POINTER_TYPE to
      METHOD_TYPE representation.  */
-  gcc_assert (TREE_CODE (target_type) != POINTER_TYPE
+  gcc_assert (!TYPE_PTR_P (target_type)
 	      || TREE_CODE (TREE_TYPE (target_type)) != METHOD_TYPE);
 
   gcc_assert (is_overloaded_fn (overload));
Index: cp-tree.h
===================================================================
--- cp-tree.h	(revision 197242)
+++ cp-tree.h	(working copy)
@@ -3449,7 +3449,7 @@  more_aggr_init_expr_args_p (const aggr_init_expr_a
    Keep these checks in ascending order, for speed.  */
 #define TYPE_OBJ_P(NODE)			\
   (TREE_CODE (NODE) != REFERENCE_TYPE		\
-   && TREE_CODE (NODE) != VOID_TYPE		\
+   && !VOID_TYPE_P (NODE)  		        \
    && TREE_CODE (NODE) != FUNCTION_TYPE		\
    && TREE_CODE (NODE) != METHOD_TYPE)
 
@@ -3472,7 +3472,7 @@  more_aggr_init_expr_args_p (const aggr_init_expr_a
 
 /* Returns true if NODE is a pointer to function.  */
 #define TYPE_PTRFN_P(NODE)				\
-  (TREE_CODE (NODE) == POINTER_TYPE			\
+  (TYPE_PTR_P (NODE)			                \
    && TREE_CODE (TREE_TYPE (NODE)) == FUNCTION_TYPE)
 
 /* Returns true if NODE is a reference to function.  */
Index: cvt.c
===================================================================
--- cvt.c	(revision 197242)
+++ cvt.c	(working copy)
@@ -105,14 +105,14 @@  cp_convert_to_pointer (tree type, tree expr, tsubs
     }
 
   /* Handle anachronistic conversions from (::*)() to cv void* or (*)().  */
-  if (TREE_CODE (type) == POINTER_TYPE
+  if (TYPE_PTR_P (type)
       && (TREE_CODE (TREE_TYPE (type)) == FUNCTION_TYPE
 	  || VOID_TYPE_P (TREE_TYPE (type))))
     {
       if (TYPE_PTRMEMFUNC_P (intype)
 	  || TREE_CODE (intype) == METHOD_TYPE)
 	return convert_member_func_to_ptr (type, expr, complain);
-      if (TREE_CODE (TREE_TYPE (expr)) == POINTER_TYPE)
+      if (TYPE_PTR_P (TREE_TYPE (expr)))
 	return build_nop (type, expr);
       intype = TREE_TYPE (expr);
     }
@@ -127,7 +127,7 @@  cp_convert_to_pointer (tree type, tree expr, tsubs
       intype = TYPE_MAIN_VARIANT (intype);
 
       if (TYPE_MAIN_VARIANT (type) != intype
-	  && TREE_CODE (type) == POINTER_TYPE
+	  && TYPE_PTR_P (type)
 	  && TREE_CODE (TREE_TYPE (type)) == RECORD_TYPE
 	  && MAYBE_CLASS_TYPE_P (TREE_TYPE (type))
 	  && MAYBE_CLASS_TYPE_P (TREE_TYPE (intype))
@@ -483,7 +483,7 @@  convert_to_reference (tree reftype, tree expr, int
       /* B* bp; A& ar = (A&)bp; is valid, but it's probably not what they
 	 meant.  */
       if ((complain & tf_warning)
-	  && TREE_CODE (intype) == POINTER_TYPE
+	  && TYPE_PTR_P (intype)
 	  && (comptypes (TREE_TYPE (intype), type,
 			 COMPARE_BASE | COMPARE_DERIVED)))
 	warning_at (loc, 0, "casting %qT to %qT does not dereference pointer",
@@ -723,7 +723,7 @@  ocp_convert (tree type, tree expr, int convtype, i
 	  if (((INTEGRAL_OR_ENUMERATION_TYPE_P (intype)
 		|| TREE_CODE (intype) == REAL_TYPE)
 	       && ! (convtype & CONV_STATIC))
-	      || TREE_CODE (intype) == POINTER_TYPE)
+	      || TYPE_PTR_P (intype))
 	    {
 	      if (complain & tf_error)
 		permerror (loc, "conversion from %q#T to %q#T", intype, type);
@@ -758,7 +758,7 @@  ocp_convert (tree type, tree expr, int convtype, i
 	}
       if (code == BOOLEAN_TYPE)
 	{
-	  if (TREE_CODE (intype) == VOID_TYPE)
+	  if (VOID_TYPE_P (intype))
 	    {
 	      if (complain & tf_error)
 		error_at (loc,
@@ -1457,8 +1457,7 @@  convert_force (tree type, tree expr, int convtype,
 							      complain));
 
   /* From typeck.c convert_for_assignment */
-  if (((TREE_CODE (TREE_TYPE (e)) == POINTER_TYPE && TREE_CODE (e) == ADDR_EXPR
-	&& TREE_CODE (TREE_TYPE (e)) == POINTER_TYPE
+  if (((TYPE_PTR_P (TREE_TYPE (e)) && TREE_CODE (e) == ADDR_EXPR
 	&& TREE_CODE (TREE_TYPE (TREE_TYPE (e))) == METHOD_TYPE)
        || integer_zerop (e)
        || TYPE_PTRMEMFUNC_P (TREE_TYPE (e)))
Index: cxx-pretty-print.c
===================================================================
--- cxx-pretty-print.c	(revision 197242)
+++ cxx-pretty-print.c	(working copy)
@@ -530,7 +530,7 @@  pp_cxx_postfix_expression (cxx_pretty_printer *pp,
 	    if (TREE_CODE (object) == ADDR_EXPR)
 	      object = TREE_OPERAND (object, 0);
 
-	    if (TREE_CODE (TREE_TYPE (object)) != POINTER_TYPE)
+	    if (!TYPE_PTR_P (TREE_TYPE (object)))
 	      {
 		pp_cxx_postfix_expression (pp, object);
 		pp_cxx_dot (pp);
@@ -1358,7 +1358,7 @@  pp_cxx_ptr_operator (cxx_pretty_printer *pp, tree
 	pp_cxx_ptr_operator (pp, TREE_TYPE (t));
       pp_c_attributes_display (pp_c_base (pp),
 			       TYPE_ATTRIBUTES (TREE_TYPE (t)));
-      if (TREE_CODE (t) == POINTER_TYPE)
+      if (TYPE_PTR_P (t))
 	{
 	  pp_star (pp);
 	  pp_cxx_cv_qualifier_seq (pp, t);
Index: decl.c
===================================================================
--- decl.c	(revision 197242)
+++ decl.c	(working copy)
@@ -1348,7 +1348,7 @@  duplicate_decls (tree newdecl, tree olddecl, bool
 		  {
 		    tree t = TREE_VALUE (t1);
 
-		    if (TREE_CODE (t) == POINTER_TYPE
+		    if (TYPE_PTR_P (t)
 			&& TYPE_NAME (TREE_TYPE (t))
 			&& DECL_NAME (TYPE_NAME (TREE_TYPE (t)))
 			   == get_identifier ("FILE")
@@ -4451,7 +4451,7 @@  start_decl (const cp_declarator *declarator,
 
   deprecated_state = DEPRECATED_NORMAL;
 
-  if (decl == NULL_TREE || TREE_CODE (decl) == VOID_TYPE
+  if (decl == NULL_TREE || VOID_TYPE_P (decl)
       || decl == error_mark_node)
     return error_mark_node;
 
@@ -11487,7 +11487,7 @@  grok_op_properties (tree decl, bool complain)
 	  if (ref)
 	    t = TYPE_MAIN_VARIANT (TREE_TYPE (t));
 
-	  if (TREE_CODE (t) == VOID_TYPE)
+	  if (VOID_TYPE_P (t))
             warning (OPT_Wconversion,
                      ref
                      ? G_("conversion to a reference to void "
@@ -12951,7 +12951,7 @@  start_preparsed_function (tree decl1, tree attrs,
   bool honor_interface;
 
   /* Sanity check.  */
-  gcc_assert (TREE_CODE (TREE_VALUE (void_list_node)) == VOID_TYPE);
+  gcc_assert (VOID_TYPE_P (TREE_VALUE (void_list_node)));
   gcc_assert (TREE_CHAIN (void_list_node) == NULL_TREE);
 
   fntype = TREE_TYPE (decl1);
@@ -13016,7 +13016,7 @@  start_preparsed_function (tree decl1, tree attrs,
   /* Effective C++ rule 15.  */
   if (warn_ecpp
       && DECL_OVERLOADED_OPERATOR_P (decl1) == NOP_EXPR
-      && TREE_CODE (TREE_TYPE (fntype)) == VOID_TYPE)
+      && VOID_TYPE_P (TREE_TYPE (fntype)))
     warning (OPT_Weffc__, "%<operator=%> should return a reference to %<*this%>");
 
   /* Make the init_value nonzero so pushdecl knows this is not tentative.
@@ -13187,7 +13187,7 @@  start_preparsed_function (tree decl1, tree attrs,
       tree t = DECL_ARGUMENTS (decl1);
 
       gcc_assert (t != NULL_TREE && TREE_CODE (t) == PARM_DECL);
-      gcc_assert (TREE_CODE (TREE_TYPE (t)) == POINTER_TYPE);
+      gcc_assert (TYPE_PTR_P (TREE_TYPE (t)));
 
       cp_function_chain->x_current_class_ref
 	= cp_build_indirect_ref (t, RO_NULL, tf_warning_or_error);
@@ -13415,7 +13415,7 @@  store_parm_decls (tree current_function_parms)
 	  if (TREE_CODE (parm) == PARM_DECL)
 	    {
 	      if (DECL_NAME (parm) == NULL_TREE
-		  || TREE_CODE (parm) != VOID_TYPE)
+		  || !VOID_TYPE_P (parm))
 		pushdecl (parm);
 	      else
 		error ("parameter %qD declared void", parm);
@@ -13838,7 +13838,7 @@  finish_function (int flags)
 
   /* Complain if there's just no return statement.  */
   if (warn_return_type
-      && TREE_CODE (TREE_TYPE (fntype)) != VOID_TYPE
+      && !VOID_TYPE_P (TREE_TYPE (fntype))
       && !dependent_type_p (TREE_TYPE (fntype))
       && !current_function_returns_value && !current_function_returns_null
       /* Don't complain if we abort or throw.  */
Index: decl2.c
===================================================================
--- decl2.c	(revision 197242)
+++ decl2.c	(working copy)
@@ -460,7 +460,7 @@  delete_sanity (tree exp, tree size, bool doing_vec
     }
 
   /* Deleting ptr to void is undefined behavior [expr.delete/3].  */
-  if (TREE_CODE (TREE_TYPE (type)) == VOID_TYPE)
+  if (VOID_TYPE_P (TREE_TYPE (type)))
     {
       warning (0, "deleting %qT is undefined", type);
       doing_vec = 0;
@@ -518,9 +518,9 @@  acceptable_java_type (tree type)
   if (type == error_mark_node)
     return false;
 
-  if (TREE_CODE (type) == VOID_TYPE || TYPE_FOR_JAVA (type))
+  if (VOID_TYPE_P (type) || TYPE_FOR_JAVA (type))
     return true;
-  if (TREE_CODE (type) == POINTER_TYPE || TREE_CODE (type) == REFERENCE_TYPE)
+  if (TYPE_PTR_P (type) || TREE_CODE (type) == REFERENCE_TYPE)
     {
       type = TREE_TYPE (type);
       if (TREE_CODE (type) == RECORD_TYPE)
@@ -535,7 +535,7 @@  acceptable_java_type (tree type)
 	  while (--i >= 0)
 	    {
 	      type = TREE_VEC_ELT (args, i);
-	      if (TREE_CODE (type) == POINTER_TYPE)
+	      if (TYPE_PTR_P (type))
 		type = TREE_TYPE (type);
 	      if (! TYPE_FOR_JAVA (type))
 		return false;
@@ -1024,7 +1024,7 @@  grokbitfield (const cp_declarator *declarator,
     return NULL_TREE; /* friends went bad.  */
 
   /* Pass friendly classes back.  */
-  if (TREE_CODE (value) == VOID_TYPE)
+  if (VOID_TYPE_P (value))
     return void_type_node;
 
   if (!INTEGRAL_OR_ENUMERATION_TYPE_P (TREE_TYPE (value))
@@ -1234,7 +1234,7 @@  cp_reconstruct_complex_type (tree type, tree botto
 {
   tree inner, outer;
 
-  if (TREE_CODE (type) == POINTER_TYPE)
+  if (TYPE_PTR_P (type))
     {
       inner = cp_reconstruct_complex_type (TREE_TYPE (type), bottom);
       outer = build_pointer_type_for_mode (inner, TYPE_MODE (type),
Index: error.c
===================================================================
--- error.c	(revision 197242)
+++ error.c	(working copy)
@@ -708,7 +708,7 @@  dump_type_prefix (tree t, int flags)
 	    pp_c_attributes_display (pp_c_base (cxx_pp),
 				     TYPE_ATTRIBUTES (sub));
 	  }
-	if (TREE_CODE (t) == POINTER_TYPE)
+	if (TYPE_PTR_P (t))
 	  pp_character(cxx_pp, '*');
 	else if (TREE_CODE (t) == REFERENCE_TYPE)
 	{
@@ -2108,7 +2108,7 @@  dump_expr (tree t, int flags)
 	{
 	  tree next = TREE_TYPE (TREE_TYPE (t));
 
-	  while (TREE_CODE (next) == POINTER_TYPE)
+	  while (TYPE_PTR_P (next))
 	    next = TREE_TYPE (next);
 
 	  if (TREE_CODE (next) == FUNCTION_TYPE)
Index: except.c
===================================================================
--- except.c	(revision 197242)
+++ except.c	(working copy)
@@ -277,7 +277,7 @@  push_eh_cleanup (tree type)
 static bool
 decl_is_java_type (tree decl, int err)
 {
-  bool r = (TREE_CODE (decl) == POINTER_TYPE
+  bool r = (TYPE_PTR_P (decl)
 	    && TREE_CODE (TREE_TYPE (decl)) == RECORD_TYPE
 	    && TYPE_FOR_JAVA (TREE_TYPE (decl)));
 
@@ -930,7 +930,7 @@  complete_ptr_ref_or_void_ptr_p (tree type, tree fr
     return 0;
 
   /* Or a pointer or ref to one, or cv void *.  */
-  is_ptr = TREE_CODE (type) == POINTER_TYPE;
+  is_ptr = TYPE_PTR_P (type);
   if (is_ptr || TREE_CODE (type) == REFERENCE_TYPE)
     {
       tree core = TREE_TYPE (type);
@@ -1026,7 +1026,7 @@  can_convert_eh (tree to, tree from)
   to = non_reference (to);
   from = non_reference (from);
 
-  if (TREE_CODE (to) == POINTER_TYPE && TREE_CODE (from) == POINTER_TYPE)
+  if (TYPE_PTR_P (to) && TYPE_PTR_P (from))
     {
       to = TREE_TYPE (to);
       from = TREE_TYPE (from);
@@ -1034,7 +1034,7 @@  can_convert_eh (tree to, tree from)
       if (! at_least_as_qualified_p (to, from))
 	return 0;
 
-      if (TREE_CODE (to) == VOID_TYPE)
+      if (VOID_TYPE_P (to))
 	return 1;
 
       /* Else fall through.  */
Index: init.c
===================================================================
--- init.c	(revision 197242)
+++ init.c	(working copy)
@@ -2294,7 +2294,7 @@  build_new_1 (vec<tree, va_gc> **placement, tree ty
 	return error_mark_node;
     }
 
-  if (TREE_CODE (elt_type) == VOID_TYPE)
+  if (VOID_TYPE_P (elt_type))
     {
       if (complain & tf_error)
         error ("invalid type %<void%> for new");
@@ -2399,7 +2399,7 @@  build_new_1 (vec<tree, va_gc> **placement, tree ty
      this now, since PLACEMENT will change in the calls below.  */
   placement_first = NULL_TREE;
   if (vec_safe_length (*placement) == 1
-      && (TREE_CODE (TREE_TYPE ((**placement)[0])) == POINTER_TYPE))
+      && (TYPE_PTR_P (TREE_TYPE ((**placement)[0]))))
     placement_first = (**placement)[0];
 
   /* Allocate the object.  */
@@ -2523,7 +2523,7 @@  build_new_1 (vec<tree, va_gc> **placement, tree ty
       && TREE_CODE (alloc_call) == CALL_EXPR
       && call_expr_nargs (alloc_call) == 2
       && TREE_CODE (TREE_TYPE (CALL_EXPR_ARG (alloc_call, 0))) == INTEGER_TYPE
-      && TREE_CODE (TREE_TYPE (CALL_EXPR_ARG (alloc_call, 1))) == POINTER_TYPE)
+      && TYPE_PTR_P (TREE_TYPE (CALL_EXPR_ARG (alloc_call, 1))))
     {
       tree placement_arg = CALL_EXPR_ARG (alloc_call, 1);
 
@@ -3742,7 +3742,7 @@  build_delete (tree type, tree addr, special_functi
 
   addr = mark_rvalue_use (addr);
 
-  if (TREE_CODE (type) == POINTER_TYPE)
+  if (TYPE_PTR_P (type))
     {
       bool complete_p = true;
 
@@ -4045,7 +4045,7 @@  build_vec_delete (tree base, tree maxindex,
 
   type = TREE_TYPE (base);
 
-  if (TREE_CODE (type) == POINTER_TYPE)
+  if (TYPE_PTR_P (type))
     {
       /* Step back one from start of vector, and read dimension.  */
       tree cookie_addr;
Index: mangle.c
===================================================================
--- mangle.c	(revision 197242)
+++ mangle.c	(working copy)
@@ -1912,7 +1912,7 @@  write_type (tree type)
 	      write_string (target_mangling);
 	      /* Add substitutions for types other than fundamental
 		 types.  */
-	      if (TREE_CODE (type) != VOID_TYPE
+	      if (!VOID_TYPE_P (type)
 		  && TREE_CODE (type) != INTEGER_TYPE
 		  && TREE_CODE (type) != REAL_TYPE
 		  && TREE_CODE (type) != BOOLEAN_TYPE)
@@ -1966,7 +1966,7 @@  write_type (tree type)
 
 	    case POINTER_TYPE:
 	    case REFERENCE_TYPE:
-	      if (TREE_CODE (type) == POINTER_TYPE)
+	      if (TYPE_PTR_P (type))
 		write_char ('P');
 	      else if (TYPE_REF_IS_RVALUE (type))
 		write_char ('O');
Index: parser.c
===================================================================
--- parser.c	(revision 197242)
+++ parser.c	(working copy)
@@ -3615,7 +3615,7 @@  lookup_literal_operator (tree name, vec<tree, va_g
 	    {
 	      tree tparm = TREE_VALUE (parmtypes);
 	      tree targ = TREE_TYPE ((*args)[ix]);
-	      bool ptr = TREE_CODE (tparm) == POINTER_TYPE;
+	      bool ptr = TYPE_PTR_P (tparm);
 	      bool arr = TREE_CODE (targ) == ARRAY_TYPE;
 	      if ((ptr || arr || !same_type_p (tparm, targ))
 		  && (!ptr || !arr
Index: pt.c
===================================================================
--- pt.c	(revision 197242)
+++ pt.c	(working copy)
@@ -5140,7 +5140,7 @@  convert_nontype_argument_function (tree type, tree
   if (TREE_CODE (fn_no_ptr) != FUNCTION_DECL)
     {
       error ("%qE is not a valid template argument for type %qT", expr, type);
-      if (TREE_CODE (type) == POINTER_TYPE)
+      if (TYPE_PTR_P (type))
 	error ("it must be the address of a function with external linkage");
       else
 	error ("it must be the name of a function with external linkage");
@@ -5547,7 +5547,7 @@  convert_nontype_argument (tree type, tree expr, ts
 	  tree addr = TREE_OPERAND (probe, 0);
 	  if (TREE_CODE (probe_type) == REFERENCE_TYPE
 	      && TREE_CODE (addr) == ADDR_EXPR
-	      && TREE_CODE (TREE_TYPE (addr)) == POINTER_TYPE
+	      && TYPE_PTR_P (TREE_TYPE (addr))
 	      && (same_type_ignoring_top_level_qualifiers_p
 		  (TREE_TYPE (probe_type),
 		   TREE_TYPE (TREE_TYPE (addr)))))
@@ -5566,7 +5566,7 @@  convert_nontype_argument (tree type, tree expr, ts
       tree probe = expr;
       STRIP_NOPS (probe);
       if (TREE_CODE (probe) == ADDR_EXPR
-	  && TREE_CODE (TREE_TYPE (probe)) == POINTER_TYPE)
+	  && TYPE_PTR_P (TREE_TYPE (probe)))
 	{
 	  /* Skip the ADDR_EXPR only if it is part of the decay for
 	     an array. Otherwise, it is part of the original argument
@@ -11527,7 +11527,7 @@  tsubst (tree t, tree args, tsubst_flags_t complain
 	  only enforce this check in strict C++98 mode.  */
 	if ((TREE_CODE (type) == REFERENCE_TYPE
 	     && (((cxx_dialect == cxx98) && flag_iso) || code != REFERENCE_TYPE))
-	    || (code == REFERENCE_TYPE && TREE_CODE (type) == VOID_TYPE))
+	    || (code == REFERENCE_TYPE && VOID_TYPE_P (type)))
 	  {
 	    static location_t last_loc;
 
@@ -11537,7 +11537,7 @@  tsubst (tree t, tree args, tsubst_flags_t complain
 	    if (complain & tf_error
 		&& last_loc != input_location)
 	      {
-		if (TREE_CODE (type) == VOID_TYPE)
+		if (VOID_TYPE_P (type))
 		  error ("forming reference to void");
                else if (code == POINTER_TYPE)
                  error ("forming pointer to reference type %qT", type);
@@ -11600,7 +11600,7 @@  tsubst (tree t, tree args, tsubst_flags_t complain
 	      error ("creating pointer to member reference type %qT", type);
 	    return error_mark_node;
 	  }
-	if (TREE_CODE (type) == VOID_TYPE)
+	if (VOID_TYPE_P (type))
 	  {
 	    if (complain & tf_error)
 	      error ("creating pointer to member of type void");
@@ -11660,7 +11660,7 @@  tsubst (tree t, tree args, tsubst_flags_t complain
 	   -- Attempting to create an array with an element type that
 	      is void, a function type, or a reference type, or [DR337]
 	      an abstract class type.  */
-	if (TREE_CODE (type) == VOID_TYPE
+	if (VOID_TYPE_P (type)
 	    || TREE_CODE (type) == FUNCTION_TYPE
 	    || TREE_CODE (type) == REFERENCE_TYPE)
 	  {
@@ -16793,7 +16793,7 @@  unify (tree tparms, tree targs, tree parm, tree ar
 
     case POINTER_TYPE:
       {
-	if (TREE_CODE (arg) != POINTER_TYPE)
+	if (!TYPE_PTR_P (arg))
 	  return unify_type_mismatch (explain_p, parm, arg);
 
 	/* [temp.deduct.call]
@@ -19378,7 +19378,7 @@  dependent_type_p_r (tree type)
     return (dependent_type_p (TYPE_PTRMEM_CLASS_TYPE (type))
 	    || dependent_type_p (TYPE_PTRMEM_POINTED_TO_TYPE
 					   (type)));
-  else if (TREE_CODE (type) == POINTER_TYPE
+  else if (TYPE_PTR_P (type)
 	   || TREE_CODE (type) == REFERENCE_TYPE)
     return dependent_type_p (TREE_TYPE (type));
   else if (TREE_CODE (type) == FUNCTION_TYPE
Index: rtti.c
===================================================================
--- rtti.c	(revision 197242)
+++ rtti.c	(working copy)
@@ -173,7 +173,7 @@  build_headof (tree exp)
   tree offset;
   tree index;
 
-  gcc_assert (TREE_CODE (type) == POINTER_TYPE);
+  gcc_assert (TYPE_PTR_P (type));
   type = TREE_TYPE (type);
 
   if (!TYPE_POLYMORPHIC_P (type))
@@ -327,7 +327,7 @@  build_typeid (tree exp, tsubst_flags_t complain)
   /* FIXME when integrating with c_fully_fold, mark
      resolves_to_fixed_type_p case as a non-constant expression.  */
   if (INDIRECT_REF_P (exp)
-      && TREE_CODE (TREE_TYPE (TREE_OPERAND (exp, 0))) == POINTER_TYPE
+      && TYPE_PTR_P (TREE_TYPE (TREE_OPERAND (exp, 0)))
       && TYPE_POLYMORPHIC_P (TREE_TYPE (exp))
       && ! resolves_to_fixed_type_p (exp, &nonnull)
       && ! nonnull)
@@ -528,7 +528,7 @@  build_dynamic_cast_1 (tree type, tree expr, tsubst
   switch (tc)
     {
     case POINTER_TYPE:
-      if (TREE_CODE (TREE_TYPE (type)) == VOID_TYPE)
+      if (VOID_TYPE_P (TREE_TYPE (type)))
 	break;
       /* Fall through.  */
     case REFERENCE_TYPE:
@@ -559,7 +559,7 @@  build_dynamic_cast_1 (tree type, tree expr, tsubst
 
       expr = mark_rvalue_use (expr);
 
-      if (TREE_CODE (exprtype) != POINTER_TYPE)
+      if (!TYPE_PTR_P (exprtype))
 	{
 	  errstr = _("source is not a pointer");
 	  goto fail;
@@ -620,7 +620,7 @@  build_dynamic_cast_1 (tree type, tree expr, tsubst
       {
 	expr = build_base_path (PLUS_EXPR, convert_from_reference (expr),
 				binfo, 0, complain);
-	if (TREE_CODE (exprtype) == POINTER_TYPE)
+	if (TYPE_PTR_P (exprtype))
 	  expr = rvalue (expr);
 	return expr;
       }
@@ -822,7 +822,7 @@  target_incomplete_p (tree type)
 	  return true;
 	type = TYPE_PTRMEM_POINTED_TO_TYPE (type);
       }
-    else if (TREE_CODE (type) == POINTER_TYPE)
+    else if (TYPE_PTR_P (type))
       type = TREE_TYPE (type);
     else
       return !COMPLETE_OR_VOID_TYPE_P (type);
@@ -1053,7 +1053,7 @@  typeinfo_in_lib_p (tree type)
 {
   /* The typeinfo objects for `T*' and `const T*' are in the runtime
      library for simple types T.  */
-  if (TREE_CODE (type) == POINTER_TYPE
+  if (TYPE_PTR_P (type)
       && (cp_type_quals (TREE_TYPE (type)) == TYPE_QUAL_CONST
 	  || cp_type_quals (TREE_TYPE (type)) == TYPE_UNQUALIFIED))
     type = TREE_TYPE (type);
Index: semantics.c
===================================================================
--- semantics.c	(revision 197242)
+++ semantics.c	(working copy)
@@ -4881,7 +4881,7 @@  finish_omp_for (location_t locus, tree declv, tree
 	}
 
       if (!INTEGRAL_TYPE_P (TREE_TYPE (decl))
-	  && TREE_CODE (TREE_TYPE (decl)) != POINTER_TYPE)
+	  && !TYPE_PTR_P (TREE_TYPE (decl)))
 	{
 	  error_at (elocus, "invalid type for iteration variable %qE", decl);
 	  return NULL;
@@ -6825,7 +6825,7 @@  cxx_eval_call_expression (const constexpr_call *ol
 	    {
 	      tree ob_arg = get_nth_callarg (t, 0);
 	      STRIP_NOPS (ob_arg);
-	      gcc_assert (TREE_CODE (TREE_TYPE (ob_arg)) == POINTER_TYPE
+	      gcc_assert (TYPE_PTR_P (TREE_TYPE (ob_arg))
 			  && CLASS_TYPE_P (TREE_TYPE (TREE_TYPE (ob_arg))));
 	      result = adjust_temp_type (TREE_TYPE (TREE_TYPE (ob_arg)),
 					 result);
@@ -9589,7 +9589,7 @@  maybe_resolve_dummy (tree object)
     return object;
 
   tree type = TYPE_MAIN_VARIANT (TREE_TYPE (object));
-  gcc_assert (TREE_CODE (type) != POINTER_TYPE);
+  gcc_assert (!TYPE_PTR_P (type));
 
   if (type != current_class_type
       && current_class_type
Index: tree.c
===================================================================
--- tree.c	(revision 197242)
+++ tree.c	(working copy)
@@ -309,7 +309,7 @@  build_target_expr (tree decl, tree value, tsubst_f
   gcc_assert (VOID_TYPE_P (TREE_TYPE (value))
 	      || TREE_TYPE (decl) == TREE_TYPE (value)
 	      /* On ARM ctors return 'this'.  */
-	      || (TREE_CODE (TREE_TYPE (value)) == POINTER_TYPE
+	      || (TYPE_PTR_P (TREE_TYPE (value))
 		  && TREE_CODE (value) == CALL_EXPR)
 	      || useless_type_conversion_p (TREE_TYPE (decl),
 					    TREE_TYPE (value)));
@@ -1086,7 +1086,7 @@  cp_build_qualified_type_real (tree type,
      pointer-to-member-function type, because these will be distinct
      between the unqualified and qualified types.  */
   if (result != type
-      && TREE_CODE (type) == POINTER_TYPE
+      && TYPE_PTR_P (type)
       && TREE_CODE (TREE_TYPE (type)) == METHOD_TYPE
       && TYPE_LANG_SPECIFIC (result) == TYPE_LANG_SPECIFIC (type))
     TYPE_LANG_SPECIFIC (result) = NULL;
@@ -1095,7 +1095,7 @@  cp_build_qualified_type_real (tree type,
      type of a pointer-to-method type, which could have the same
      sharing problem described above.  */
   if (TYPE_CANONICAL (result) != TYPE_CANONICAL (type)
-      && TREE_CODE (type) == POINTER_TYPE
+      && TYPE_PTR_P (type)
       && TREE_CODE (TREE_TYPE (type)) == METHOD_TYPE
       && (TYPE_LANG_SPECIFIC (TYPE_CANONICAL (result)) 
           == TYPE_LANG_SPECIFIC (TYPE_CANONICAL (type))))
Index: typeck.c
===================================================================
--- typeck.c	(revision 197242)
+++ typeck.c	(working copy)
@@ -483,7 +483,7 @@  composite_pointer_type_r (tree t1, tree t2,
   tree attributes;
 
   /* Determine the types pointed to by T1 and T2.  */
-  if (TREE_CODE (t1) == POINTER_TYPE)
+  if (TYPE_PTR_P (t1))
     {
       pointee1 = TREE_TYPE (t1);
       pointee2 = TREE_TYPE (t2);
@@ -503,8 +503,7 @@  composite_pointer_type_r (tree t1, tree t2,
      types.  */
   if (same_type_ignoring_top_level_qualifiers_p (pointee1, pointee2))
     result_type = pointee1;
-  else if ((TREE_CODE (pointee1) == POINTER_TYPE
-	    && TREE_CODE (pointee2) == POINTER_TYPE)
+  else if ((TYPE_PTR_P (pointee1) && TYPE_PTR_P (pointee2))
 	   || (TYPE_PTRMEM_P (pointee1) && TYPE_PTRMEM_P (pointee2)))
     {
       result_type = composite_pointer_type_r (pointee1, pointee2, operation,
@@ -581,7 +580,7 @@  composite_pointer_type (tree t1, tree t2, tree arg
        and cv2.
 
     If either type is a pointer to void, make sure it is T1.  */
-  if (TREE_CODE (t2) == POINTER_TYPE && VOID_TYPE_P (TREE_TYPE (t2)))
+  if (TYPE_PTR_P (t2) && VOID_TYPE_P (TREE_TYPE (t2)))
     {
       tree t;
       t = t1;
@@ -590,7 +589,7 @@  composite_pointer_type (tree t1, tree t2, tree arg
     }
 
   /* Now, if T1 is a pointer to void, merge the qualifiers.  */
-  if (TREE_CODE (t1) == POINTER_TYPE && VOID_TYPE_P (TREE_TYPE (t1)))
+  if (TYPE_PTR_P (t1) && VOID_TYPE_P (TREE_TYPE (t1)))
     {
       tree attributes;
       tree result_type;
@@ -628,8 +627,8 @@  composite_pointer_type (tree t1, tree t2, tree arg
       return build_type_attribute_variant (result_type, attributes);
     }
 
-  if (c_dialect_objc () && TREE_CODE (t1) == POINTER_TYPE
-      && TREE_CODE (t2) == POINTER_TYPE)
+  if (c_dialect_objc () && TYPE_PTR_P (t1)
+      && TYPE_PTR_P (t2))
     {
       if (objc_have_common_type (t1, t2, -3, NULL_TREE))
 	return objc_common_type (t1, t2);
@@ -637,7 +636,7 @@  composite_pointer_type (tree t1, tree t2, tree arg
 
   /* [expr.eq] permits the application of a pointer conversion to
      bring the pointers to a common type.  */
-  if (TREE_CODE (t1) == POINTER_TYPE && TREE_CODE (t2) == POINTER_TYPE
+  if (TYPE_PTR_P (t1) && TYPE_PTR_P (t2)
       && CLASS_TYPE_P (TREE_TYPE (t1))
       && CLASS_TYPE_P (TREE_TYPE (t2))
       && !same_type_ignoring_top_level_qualifiers_p (TREE_TYPE (t1),
@@ -959,8 +958,7 @@  comp_except_types (tree a, tree b, bool exact)
       if (cp_type_quals (a) || cp_type_quals (b))
 	return false;
 
-      if (TREE_CODE (a) == POINTER_TYPE
-	  && TREE_CODE (b) == POINTER_TYPE)
+      if (TYPE_PTR_P (a) && TYPE_PTR_P (b))
 	{
 	  a = TREE_TYPE (a);
 	  b = TREE_TYPE (b);
@@ -1553,7 +1551,7 @@  tree
 cxx_sizeof_nowarn (tree type)
 {
   if (TREE_CODE (type) == FUNCTION_TYPE
-      || TREE_CODE (type) == VOID_TYPE
+      || VOID_TYPE_P (type)
       || TREE_CODE (type) == ERROR_MARK)
     return size_one_node;
   else if (!COMPLETE_TYPE_P (type))
@@ -2069,7 +2067,7 @@  string_conv_p (const_tree totype, const_tree exp,
 {
   tree t;
 
-  if (TREE_CODE (totype) != POINTER_TYPE)
+  if (!TYPE_PTR_P (totype))
     return 0;
 
   t = TREE_TYPE (totype);
@@ -3091,7 +3089,7 @@  cp_build_array_ref (location_t loc, tree array, tr
     if (ar == error_mark_node || ind == error_mark_node)
       return error_mark_node;
 
-    if (TREE_CODE (TREE_TYPE (ar)) != POINTER_TYPE)
+    if (!TYPE_PTR_P (TREE_TYPE (ar)))
       {
 	if (complain & tf_error)
 	  error_at (loc, "subscripted value is neither array nor pointer");
@@ -3401,11 +3399,10 @@  cp_build_function_call_vec (tree function, vec<tre
       return error_mark_node;
     }
 
-  is_method = (TREE_CODE (fntype) == POINTER_TYPE
+  is_method = (TYPE_PTR_P (fntype)
 	       && TREE_CODE (TREE_TYPE (fntype)) == METHOD_TYPE);
 
-  if (!((TREE_CODE (fntype) == POINTER_TYPE
-	 && TREE_CODE (TREE_TYPE (fntype)) == FUNCTION_TYPE)
+  if (!(TYPE_PTRFN_P (fntype)
 	|| is_method
 	|| TREE_CODE (function) == TEMPLATE_ID_EXPR))
     {
@@ -4823,7 +4820,7 @@  pointer_diff (tree op0, tree op1, tree ptrtype, ts
   if (!complete_type_or_else (target_type, NULL_TREE))
     return error_mark_node;
 
-  if (TREE_CODE (target_type) == VOID_TYPE)
+  if (VOID_TYPE_P (target_type))
     {
       if (complain & tf_error)
 	permerror (input_location, "ISO C++ forbids using pointer of "
@@ -5308,7 +5305,7 @@  cp_build_addr_expr_1 (tree arg, bool strict_lvalue
       val = build_address (arg);
     }
 
-  if (TREE_CODE (argtype) == POINTER_TYPE
+  if (TYPE_PTR_P (argtype)
       && TREE_CODE (TREE_TYPE (argtype)) == METHOD_TYPE)
     {
       build_ptrmemfunc_type (argtype);
@@ -5536,7 +5533,7 @@  cp_build_unary_op (enum tree_code code, tree xarg,
 
 	/* Compute the increment.  */
 
-	if (TREE_CODE (argtype) == POINTER_TYPE)
+	if (TYPE_PTR_P (argtype))
 	  {
 	    tree type = complete_type (TREE_TYPE (argtype));
 
@@ -6244,7 +6241,7 @@  build_static_cast_1 (tree type, tree expr, bool c_
   /* [expr.static.cast]
 
      Any expression can be explicitly converted to type cv void.  */
-  if (TREE_CODE (type) == VOID_TYPE)
+  if (VOID_TYPE_P (type))
     return convert_to_void (expr, ICV_CAST, complain);
 
   /* [class.abstract]
@@ -6366,7 +6363,7 @@  build_static_cast_1 (tree type, tree expr, bool c_
      converted to a pointer to object type.  A value of type pointer
      to object converted to "pointer to cv void" and back to the
      original pointer type will have its original value.  */
-  if (TREE_CODE (intype) == POINTER_TYPE
+  if (TYPE_PTR_P (intype)
       && VOID_TYPE_P (TREE_TYPE (intype))
       && TYPE_PTROB_P (type))
     {
@@ -6886,7 +6883,7 @@  cp_build_c_cast (tree type, tree expr, tsubst_flag
     {
       /* Allow casting from T1* to T2[] because Cfront allows it.
 	 NIHCL uses it. It is not valid ISO C++ however.  */
-      if (TREE_CODE (TREE_TYPE (expr)) == POINTER_TYPE)
+      if (TYPE_PTR_P (TREE_TYPE (expr)))
 	{
           if (complain & tf_error)
             permerror (input_location, "ISO C++ forbids casting to an array type %qT", type);
@@ -6910,7 +6907,7 @@  cp_build_c_cast (tree type, tree expr, tsubst_flag
       return error_mark_node;
     }
 
-  if (TREE_CODE (type) == POINTER_TYPE
+  if (TYPE_PTR_P (type)
       && TREE_CODE (TREE_TYPE (value)) == INTEGER_TYPE
       /* Casting to an integer of smaller size is an error detected elsewhere.  */
       && TYPE_PRECISION (type) > TYPE_PRECISION (TREE_TYPE (value))
@@ -8420,7 +8417,7 @@  comp_ptr_ttypes_real (tree to, tree from, int cons
       if (TREE_CODE (to) == VECTOR_TYPE)
 	is_opaque_pointer = vector_targets_convertible_p (to, from);
 
-      if (TREE_CODE (to) != POINTER_TYPE && !TYPE_PTRDATAMEM_P (to))
+      if (!TYPE_PTR_P (to) && !TYPE_PTRDATAMEM_P (to))
 	return ((constp >= 0 || to_more_cv_qualified)
 		&& (is_opaque_pointer
 		    || same_type_ignoring_top_level_qualifiers_p (to, from)));
@@ -8484,9 +8481,9 @@  ptr_reasonably_similar (const_tree to, const_tree
   for (; ; to = TREE_TYPE (to), from = TREE_TYPE (from))
     {
       /* Any target type is similar enough to void.  */
-      if (TREE_CODE (to) == VOID_TYPE)
+      if (VOID_TYPE_P (to))
 	return !error_type_p (from);
-      if (TREE_CODE (from) == VOID_TYPE)
+      if (VOID_TYPE_P (from))
 	return !error_type_p (to);
 
       if (TREE_CODE (to) != TREE_CODE (from))
@@ -8509,7 +8506,7 @@  ptr_reasonably_similar (const_tree to, const_tree
       if (TREE_CODE (to) == FUNCTION_TYPE)
 	return !error_type_p (to) && !error_type_p (from);
 
-      if (TREE_CODE (to) != POINTER_TYPE)
+      if (!TYPE_PTR_P (to))
 	return comptypes
 	  (TYPE_MAIN_VARIANT (to), TYPE_MAIN_VARIANT (from),
 	   COMPARE_BASE | COMPARE_DERIVED);
@@ -8538,7 +8535,7 @@  comp_ptr_ttypes_const (tree to, tree from)
       if (TREE_CODE (to) == VECTOR_TYPE)
 	is_opaque_pointer = vector_targets_convertible_p (to, from);
 
-      if (TREE_CODE (to) != POINTER_TYPE)
+      if (!TYPE_PTR_P (to))
 	return (is_opaque_pointer
 		|| same_type_ignoring_top_level_qualifiers_p (to, from));
     }
@@ -8758,8 +8755,7 @@  casts_away_constness (tree t1, tree t2, tsubst_fla
 
   /* Casting away constness is only something that makes sense for
      pointer or reference types.  */
-  if (TREE_CODE (t1) != POINTER_TYPE
-      || TREE_CODE (t2) != POINTER_TYPE)
+  if (!TYPE_PTR_P (t1) || !TYPE_PTR_P (t2))
     return false;
 
   /* Top-level qualifiers don't matter.  */
@@ -8869,7 +8865,7 @@  check_literal_operator_args (const_tree decl,
 	  tree t = TREE_VALUE (argtype);
 	  ++arity;
 
-	  if (TREE_CODE (t) == POINTER_TYPE)
+	  if (TYPE_PTR_P (t))
 	    {
 	      bool maybe_raw_p = false;
 	      t = TREE_TYPE (t);
Index: typeck2.c
===================================================================
--- typeck2.c	(revision 197242)
+++ typeck2.c	(working copy)
@@ -1585,7 +1585,7 @@  build_x_arrow (location_t loc, tree expr, tsubst_f
   else
     last_rval = decay_conversion (expr, complain);
 
-  if (TREE_CODE (TREE_TYPE (last_rval)) == POINTER_TYPE)
+  if (TYPE_PTR_P (TREE_TYPE (last_rval)))
     {
       if (processing_template_decl)
 	{
@@ -1851,7 +1851,7 @@  add_exception_specifier (tree list, tree spec, int
   /* [except.spec] 1, type in an exception specifier shall not be
      incomplete, or pointer or ref to incomplete other than pointer
      to cv void.  */
-  is_ptr = TREE_CODE (core) == POINTER_TYPE;
+  is_ptr = TYPE_PTR_P (core);
   if (is_ptr || TREE_CODE (core) == REFERENCE_TYPE)
     core = TREE_TYPE (core);
   if (complain < 0)