FreeBSD/contrib/gcc/cp/error.c
/* Dump a human readable string for the decl T under control of FLAGS.  */
Dump a human readable string for the decl T under control of FLAGS.
Dump a human readable string for the decl T under control of FLAGS .
static void
dump_decl (tree t, int flags)
{
  if (t == NULL_TREE)
    return;
  switch (TREE_CODE (t))
    {
    case TYPE_DECL:
      if (DECL_ARTIFICIAL (t))
	{
	  if ((flags & TFF_DECL_SPECIFIERS)
	      && TREE_CODE (TREE_TYPE (t)) == TEMPLATE_TYPE_PARM)
	    pp_cxx_identifier (cxx_pp, "class");
	  dump_type (TREE_TYPE (t), flags);
	  break;
	}
      if (flags & TFF_DECL_SPECIFIERS)
	pp_cxx_identifier (cxx_pp, "typedef");
      dump_simple_decl (t, DECL_ORIGINAL_TYPE (t)
			? DECL_ORIGINAL_TYPE (t) : TREE_TYPE (t),
			flags);
      break;
    case VAR_DECL:
      if (DECL_NAME (t) && VTABLE_NAME_P (DECL_NAME (t)))
	{
	  pp_string (cxx_pp, "vtable for ");
	  gcc_assert (TYPE_P (DECL_CONTEXT (t)));
	  dump_type (DECL_CONTEXT (t), flags);
	  break;
	}
    case FIELD_DECL:
    case PARM_DECL:
      dump_simple_decl (t, TREE_TYPE (t), flags);
      break;
    case RESULT_DECL:
      pp_string (cxx_pp, "<return value> ");
      dump_simple_decl (t, TREE_TYPE (t), flags);
      break;
    case NAMESPACE_DECL:
      if (flags & TFF_DECL_SPECIFIERS)
	pp_cxx_declaration (cxx_pp, t);
      else
	{
	  dump_scope (CP_DECL_CONTEXT (t), flags);
	  if (DECL_NAME (t) == NULL_TREE)
	    pp_identifier (cxx_pp, "<unnamed>");
	  else
	    pp_cxx_tree_identifier (cxx_pp, DECL_NAME (t));
	}
      break;
    case SCOPE_REF:
      pp_expression (cxx_pp, t);
      break;
    case ARRAY_REF:
      dump_decl (TREE_OPERAND (t, 0), flags);
      pp_cxx_left_bracket (cxx_pp);
      dump_decl (TREE_OPERAND (t, 1), flags);
      pp_cxx_right_bracket (cxx_pp);
      break;
    case RECORD_TYPE:
    case UNION_TYPE:
    case ENUMERAL_TYPE:
      dump_type (t, flags);
      break;
    case BIT_NOT_EXPR:
      pp_cxx_complement (cxx_pp);
      dump_type (TREE_OPERAND (t, 0), flags);
      break;
    case TYPE_EXPR:
      gcc_unreachable ();
      break;
    case IDENTIFIER_NODE:
      if (IDENTIFIER_TYPENAME_P (t))
	{
	  pp_cxx_identifier (cxx_pp, "operator");
	  dump_type (TREE_TYPE (t), flags);
	  break;
	}
      else
	pp_cxx_tree_identifier (cxx_pp, t);
      break;
    case OVERLOAD:
      if (OVL_CHAIN (t))
	{
	  t = OVL_CURRENT (t);
	  if (DECL_CLASS_SCOPE_P (t))
	    {
	      dump_type (DECL_CONTEXT (t), flags);
	      pp_cxx_colon_colon (cxx_pp);
	    }
	  else if (DECL_CONTEXT (t))
	    {
	      dump_decl (DECL_CONTEXT (t), flags);
	      pp_cxx_colon_colon (cxx_pp);
	    }
	  dump_decl (DECL_NAME (t), flags);
	  break;
	}
      t = OVL_CURRENT (t);
    case FUNCTION_DECL:
      if (! DECL_LANG_SPECIFIC (t))
	pp_identifier (cxx_pp, "<built-in>");
      else if (DECL_GLOBAL_CTOR_P (t) || DECL_GLOBAL_DTOR_P (t))
	dump_global_iord (t);
      else
	dump_function_decl (t, flags);
      break;
    case TEMPLATE_DECL:
      dump_template_decl (t, flags);
      break;
    case TEMPLATE_ID_EXPR:
      {
	tree name = TREE_OPERAND (t, 0);
	if (is_overloaded_fn (name))
	  name = DECL_NAME (get_first_fn (name));
	dump_decl (name, flags);
	pp_cxx_begin_template_argument_list (cxx_pp);
	if (TREE_OPERAND (t, 1))
	  dump_template_argument_list (TREE_OPERAND (t, 1), flags);
	pp_cxx_end_template_argument_list (cxx_pp);
      }
      break;
    case LABEL_DECL:
      pp_cxx_tree_identifier (cxx_pp, DECL_NAME (t));
      break;
    case CONST_DECL:
      if ((TREE_TYPE (t) != NULL_TREE && NEXT_CODE (t) == ENUMERAL_TYPE)
	  || (DECL_INITIAL (t) &&
	      TREE_CODE (DECL_INITIAL (t)) == TEMPLATE_PARM_INDEX))
	dump_simple_decl (t, TREE_TYPE (t), flags);
      else if (DECL_NAME (t))
	dump_decl (DECL_NAME (t), flags);
      else if (DECL_INITIAL (t))
	dump_expr (DECL_INITIAL (t), flags | TFF_EXPR_IN_PARENS);
      else
	pp_identifier (cxx_pp, "<enumerator>");
      break;
    case USING_DECL:
      pp_cxx_identifier (cxx_pp, "using");
      dump_type (USING_DECL_SCOPE (t), flags);
      pp_cxx_colon_colon (cxx_pp);
      dump_decl (DECL_NAME (t), flags);
      break;
    case BASELINK:
      dump_decl (BASELINK_FUNCTIONS (t), flags);
      break;
    case NON_DEPENDENT_EXPR:
      dump_expr (t, flags);
      break;
    case TEMPLATE_TYPE_PARM:
      if (flags & TFF_DECL_SPECIFIERS)
	pp_cxx_declaration (cxx_pp, t);
      else
	pp_type_id (cxx_pp, t);
      break;
    case UNBOUND_CLASS_TEMPLATE:
      dump_type (t, flags);
      break;
    default:
      pp_unsupported_tree (cxx_pp, t);
    case ERROR_MARK:
      pp_identifier (cxx_pp, "<declaration error>");
      break;
    }
}
static void dump_decl ( tree t , int flags ) { if ( t == NULL_TREE ) return ; switch ( TREE_CODE ( t ) ) { case TYPE_DECL : if ( DECL_ARTIFICIAL ( t ) ) { if ( ( flags & TFF_DECL_SPECIFIERS ) && TREE_CODE ( TREE_TYPE ( t ) ) == TEMPLATE_TYPE_PARM ) pp_cxx_identifier ( cxx_pp , " " ) ; dump_type ( TREE_TYPE ( t ) , flags ) ; break ; } if ( flags & TFF_DECL_SPECIFIERS ) pp_cxx_identifier ( cxx_pp , " " ) ; dump_simple_decl ( t , DECL_ORIGINAL_TYPE ( t ) ? DECL_ORIGINAL_TYPE ( t ) : TREE_TYPE ( t ) , flags ) ; break ; case VAR_DECL : if ( DECL_NAME ( t ) && VTABLE_NAME_P ( DECL_NAME ( t ) ) ) { pp_string ( cxx_pp , " " ) ; gcc_assert ( TYPE_P ( DECL_CONTEXT ( t ) ) ) ; dump_type ( DECL_CONTEXT ( t ) , flags ) ; break ; } case FIELD_DECL : case PARM_DECL : dump_simple_decl ( t , TREE_TYPE ( t ) , flags ) ; break ; case RESULT_DECL : pp_string ( cxx_pp , " " ) ; dump_simple_decl ( t , TREE_TYPE ( t ) , flags ) ; break ; case NAMESPACE_DECL : if ( flags & TFF_DECL_SPECIFIERS ) pp_cxx_declaration ( cxx_pp , t ) ; else { dump_scope ( CP_DECL_CONTEXT ( t ) , flags ) ; if ( DECL_NAME ( t ) == NULL_TREE ) pp_identifier ( cxx_pp , " " ) ; else pp_cxx_tree_identifier ( cxx_pp , DECL_NAME ( t ) ) ; } break ; case SCOPE_REF : pp_expression ( cxx_pp , t ) ; break ; case ARRAY_REF : dump_decl ( TREE_OPERAND ( t , 0 ) , flags ) ; pp_cxx_left_bracket ( cxx_pp ) ; dump_decl ( TREE_OPERAND ( t , 1 ) , flags ) ; pp_cxx_right_bracket ( cxx_pp ) ; break ; case RECORD_TYPE : case UNION_TYPE : case ENUMERAL_TYPE : dump_type ( t , flags ) ; break ; case BIT_NOT_EXPR : pp_cxx_complement ( cxx_pp ) ; dump_type ( TREE_OPERAND ( t , 0 ) , flags ) ; break ; case TYPE_EXPR : gcc_unreachable ( ) ; break ; case IDENTIFIER_NODE : if ( IDENTIFIER_TYPENAME_P ( t ) ) { pp_cxx_identifier ( cxx_pp , " " ) ; dump_type ( TREE_TYPE ( t ) , flags ) ; break ; } else pp_cxx_tree_identifier ( cxx_pp , t ) ; break ; case OVERLOAD : if ( OVL_CHAIN ( t ) ) { t = OVL_CURRENT ( t ) ; if ( DECL_CLASS_SCOPE_P ( t ) ) { dump_type ( DECL_CONTEXT ( t ) , flags ) ; pp_cxx_colon_colon ( cxx_pp ) ; } else if ( DECL_CONTEXT ( t ) ) { dump_decl ( DECL_CONTEXT ( t ) , flags ) ; pp_cxx_colon_colon ( cxx_pp ) ; } dump_decl ( DECL_NAME ( t ) , flags ) ; break ; } t = OVL_CURRENT ( t ) ; case FUNCTION_DECL : if ( ! DECL_LANG_SPECIFIC ( t ) ) pp_identifier ( cxx_pp , " " ) ; else if ( DECL_GLOBAL_CTOR_P ( t ) || DECL_GLOBAL_DTOR_P ( t ) ) dump_global_iord ( t ) ; else dump_function_decl ( t , flags ) ; break ; case TEMPLATE_DECL : dump_template_decl ( t , flags ) ; break ; case TEMPLATE_ID_EXPR : { tree name = TREE_OPERAND ( t , 0 ) ; if ( is_overloaded_fn ( name ) ) name = DECL_NAME ( get_first_fn ( name ) ) ; dump_decl ( name , flags ) ; pp_cxx_begin_template_argument_list ( cxx_pp ) ; if ( TREE_OPERAND ( t , 1 ) ) dump_template_argument_list ( TREE_OPERAND ( t , 1 ) , flags ) ; pp_cxx_end_template_argument_list ( cxx_pp ) ; } break ; case LABEL_DECL : pp_cxx_tree_identifier ( cxx_pp , DECL_NAME ( t ) ) ; break ; case CONST_DECL : if ( ( TREE_TYPE ( t ) != NULL_TREE && NEXT_CODE ( t ) == ENUMERAL_TYPE ) || ( DECL_INITIAL ( t ) && TREE_CODE ( DECL_INITIAL ( t ) ) == TEMPLATE_PARM_INDEX ) ) dump_simple_decl ( t , TREE_TYPE ( t ) , flags ) ; else if ( DECL_NAME ( t ) ) dump_decl ( DECL_NAME ( t ) , flags ) ; else if ( DECL_INITIAL ( t ) ) dump_expr ( DECL_INITIAL ( t ) , flags | TFF_EXPR_IN_PARENS ) ; else pp_identifier ( cxx_pp , " " ) ; break ; case USING_DECL : pp_cxx_identifier ( cxx_pp , " " ) ; dump_type ( USING_DECL_SCOPE ( t ) , flags ) ; pp_cxx_colon_colon ( cxx_pp ) ; dump_decl ( DECL_NAME ( t ) , flags ) ; break ; case BASELINK : dump_decl ( BASELINK_FUNCTIONS ( t ) , flags ) ; break ; case NON_DEPENDENT_EXPR : dump_expr ( t , flags ) ; break ; case TEMPLATE_TYPE_PARM : if ( flags & TFF_DECL_SPECIFIERS ) pp_cxx_declaration ( cxx_pp , t ) ; else pp_type_id ( cxx_pp , t ) ; break ; case UNBOUND_CLASS_TEMPLATE : dump_type ( t , flags ) ; break ; default : pp_unsupported_tree ( cxx_pp , t ) ; case ERROR_MARK : pp_identifier ( cxx_pp , " " ) ; break ; } }
Dump a human readable string for the decl T under control of FLAGS.
Dump a human readable string for the decl T under control of FLAGS .
/* Don't say 'typedef class A' */ /* Say `class T' not just `T'.  */ /* Else fall through.  */ /* So that we can do dump_decl on an aggr type.  */ /* This is a pseudo destructor call which has not been folded into
	 a PSEUDO_DTOR_EXPR yet.  */ /* These special cases are duplicated here so that other functions
	 can feed identifiers to error and get them demangled properly.  */ /* Not exactly IDENTIFIER_TYPE_VALUE.  */ /* If there's only one function, just treat it like an ordinary
	 FUNCTION_DECL.  */ /* Fall through.  */ /* Fall through to error.  */