⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 error.c

📁 gcc库的原代码,对编程有很大帮助.
💻 C
📖 第 1 页 / 共 3 页
字号:
    case TREE_VEC:    case UNINSTANTIATED_P_TYPE:    case UNION_TYPE:    case UNKNOWN_TYPE:    case VOID_TYPE:      break;    default:      sorry ("`%s' not supported by dump_type_suffix",	     tree_code_name[(int) TREE_CODE (t)]);    }}/* Return a function declaration which corresponds to the IDENTIFIER_NODE   argument.  */treeident_fndecl (t)     tree t;{  tree n = lookup_name (t, 0);  if (n == NULL_TREE)    return NULL_TREE;  if (TREE_CODE (n) == FUNCTION_DECL)    return n;  else if (TREE_CODE (n) == TREE_LIST	   && TREE_CODE (TREE_VALUE (n)) == FUNCTION_DECL)    return TREE_VALUE (n);  my_friendly_abort (66);  return NULL_TREE;}#ifndef NO_DOLLAR_IN_LABEL#  define GLOBAL_THING "_GLOBAL_$"#else#  ifndef NO_DOT_IN_LABEL#    define GLOBAL_THING "_GLOBAL_."#  else#    define GLOBAL_THING "_GLOBAL__"#  endif#endif#define GLOBAL_IORD_P(NODE) \  !strncmp(IDENTIFIER_POINTER(NODE),GLOBAL_THING,sizeof(GLOBAL_THING)-1)voiddump_global_iord (t)     tree t;{  char *name = IDENTIFIER_POINTER (t);  OB_PUTS ("(static ");  if (name [sizeof (GLOBAL_THING) - 1] == 'I')    OB_PUTS ("initializers");  else if (name [sizeof (GLOBAL_THING) - 1] == 'D')    OB_PUTS ("destructors");  else    my_friendly_abort (352);    OB_PUTS (" for ");  OB_PUTCP (input_filename);  OB_PUTC (')');}static voiddump_decl (t, v)     tree t;     int v;			/* verbosity */{  if (t == NULL_TREE)    return;  switch (TREE_CODE (t))    {    case ERROR_MARK:      OB_PUTS (" /* decl error */ ");      break;    case TYPE_DECL:      {	/* Don't say 'typedef class A' */	tree type = TREE_TYPE (t);        if (((IS_AGGR_TYPE (type) && ! TYPE_PTRMEMFUNC_P (type))	     || TREE_CODE (type) == ENUMERAL_TYPE)	    && type == TYPE_MAIN_VARIANT (type))	  {	    dump_type (type, v);	    break;	  }      }      if (v > 0)	OB_PUTS ("typedef ");      goto general;      break;          case VAR_DECL:      if (DECL_NAME (t) && VTABLE_NAME_P (DECL_NAME (t)))	{	  OB_PUTS ("vtable for ");	  dump_type (DECL_CONTEXT (t), v);	  break;	}      /* else fall through */    case FIELD_DECL:    case PARM_DECL:    general:      if (v > 0)	{	  dump_type_prefix (TREE_TYPE (t), v);	  OB_PUTC (' ');	  dump_readonly_or_volatile (t, after);	}      /* DECL_CLASS_CONTEXT isn't being set in some cases.  Hmm...  */      if (DECL_CONTEXT (t)	  && TREE_CODE_CLASS (TREE_CODE (DECL_CONTEXT (t))) == 't')	{	  dump_type (DECL_CONTEXT (t), 0);	  OB_PUTC2 (':', ':');	}      if (DECL_NAME (t))	dump_decl (DECL_NAME (t), v);      else	OB_PUTS ("{anon}");      if (v > 0)	dump_type_suffix (TREE_TYPE (t), v);      break;    case NAMESPACE_DECL:      OB_PUTID (DECL_NAME (t));      break;    case ARRAY_REF:      dump_decl (TREE_OPERAND (t, 0), v);      OB_PUTC ('[');      dump_decl (TREE_OPERAND (t, 1), v);      OB_PUTC (']');      break;      /* So that we can do dump_decl in dump_aggr_type and have it work for	 both class and function scope.  */    case RECORD_TYPE:    case UNION_TYPE:    case ENUMERAL_TYPE:      dump_type (t, v);      break;    case TYPE_EXPR:      my_friendly_abort (69);      break;      /* These special cases are duplicated here so that other functions	 can feed identifiers to cp_error and get them demangled properly. */    case IDENTIFIER_NODE:      { tree f;	if (DESTRUCTOR_NAME_P (t)	    && (f = ident_fndecl (t))	    && DECL_LANGUAGE (f) == lang_cplusplus)	  {	    OB_PUTC ('~');	    dump_decl (DECL_NAME (f), 0);	  }	else if (IDENTIFIER_TYPENAME_P (t))	  {	    OB_PUTS ("operator ");	    /* Not exactly IDENTIFIER_TYPE_VALUE.  */	    dump_type (TREE_TYPE (t), 0);	    break;	  }	else if (IDENTIFIER_OPNAME_P (t))	  {	    char *name_string = operator_name_string (t);	    OB_PUTS ("operator ");	    OB_PUTCP (name_string);	  }	else	  OB_PUTID (t);      }      break;    case FUNCTION_DECL:      if (GLOBAL_IORD_P (DECL_ASSEMBLER_NAME (t)))	dump_global_iord (DECL_ASSEMBLER_NAME (t));      else	dump_function_decl (t, v);      break;    case TEMPLATE_DECL:      {	tree args = DECL_TEMPLATE_PARMS (t);	int i, len = args ? TREE_VEC_LENGTH (args) : 0;	OB_PUTS ("template <");	for (i = 0; i < len; i++)	  {	    tree arg = TREE_VEC_ELT (args, i);	    tree defval = TREE_PURPOSE (arg);	    arg = TREE_VALUE (arg);	    if (TREE_CODE (arg) == TYPE_DECL)	      {		OB_PUTS ("class ");		OB_PUTID (DECL_NAME (arg));	      }	    else	      dump_decl (arg, 1);	    if (defval)	      {		OB_PUTS (" = ");		dump_decl (defval, 1);	      }			    OB_PUTC2 (',', ' ');	  }	if (len != 0)	  OB_UNPUT (2);	OB_PUTC2 ('>', ' ');	if (DECL_TEMPLATE_IS_CLASS (t))	  {	    OB_PUTS ("class ");	    OB_PUTID (DECL_NAME (t));	  }	else switch (NEXT_CODE (t))	  {	  case METHOD_TYPE:	  case FUNCTION_TYPE:	    dump_function_decl (t, v);	    break;	  default:	    my_friendly_abort (353);	  }      }      break;    case LABEL_DECL:      OB_PUTID (DECL_NAME (t));      break;    case CONST_DECL:      if (NEXT_CODE (t) == ENUMERAL_TYPE)	goto general;      else	dump_expr (DECL_INITIAL (t), 0);      break;    default:      sorry ("`%s' not supported by dump_decl",	     tree_code_name[(int) TREE_CODE (t)]);    }}/* Pretty printing for announce_function.  T is the declaration of the   function we are interested in seeing.  V is non-zero if we should print   the type that this function returns.  */static voiddump_function_decl (t, v)     tree t;     int v;{  tree name = DECL_ASSEMBLER_NAME (t);  tree fntype = TREE_TYPE (t);  tree parmtypes = TYPE_ARG_TYPES (fntype);  tree cname = NULL_TREE;  /* Friends have DECL_CLASS_CONTEXT set, but not DECL_CONTEXT.  */  if (DECL_CONTEXT (t))    cname = DECL_CLASS_CONTEXT (t);  /* this is for partially instantiated template methods */  else if (TREE_CODE (fntype) == METHOD_TYPE)    cname = TREE_TYPE (TREE_VALUE (parmtypes));  v = (v > 0);    if (v)    {      if (DECL_STATIC_FUNCTION_P (t))	OB_PUTS ("static ");          if (! IDENTIFIER_TYPENAME_P (name)	  && ! DECL_CONSTRUCTOR_P (t)	  && ! DESTRUCTOR_NAME_P (name))	{	  dump_type_prefix (TREE_TYPE (fntype), 1);	  OB_PUTC (' ');	}    }  if (cname)    {      dump_type (cname, 0);      OB_PUTC2 (':', ':');      if (TREE_CODE (fntype) == METHOD_TYPE && parmtypes)	parmtypes = TREE_CHAIN (parmtypes);      if (DECL_CONSTRUCTOR_FOR_VBASE_P (t))	/* Skip past "in_charge" identifier.  */	parmtypes = TREE_CHAIN (parmtypes);    }  if (DESTRUCTOR_NAME_P (name) && DECL_LANGUAGE (t) == lang_cplusplus)    parmtypes = TREE_CHAIN (parmtypes);    dump_function_name (t);    OB_PUTC ('(');  if (parmtypes)    dump_type (parmtypes, v);  else    OB_PUTS ("...");  OB_PUTC (')');  if (v && ! IDENTIFIER_TYPENAME_P (name))    dump_type_suffix (TREE_TYPE (fntype), 1);  if (TREE_CODE (fntype) == METHOD_TYPE)    {      if (IS_SIGNATURE (cname))	/* We look at the type pointed to by the `optr' field of `this.'  */	dump_readonly_or_volatile	  (TREE_TYPE (TREE_TYPE (TYPE_FIELDS (TREE_VALUE (TYPE_ARG_TYPES (fntype))))), before);      else	dump_readonly_or_volatile	  (TREE_TYPE (TREE_VALUE (TYPE_ARG_TYPES (fntype))), before);    }}/* Handle the function name for a FUNCTION_DECL node, grokking operators   and destructors properly.  */static voiddump_function_name (t)     tree t;{  tree name = DECL_NAME (t);  /* There ought to be a better way to find out whether or not something is     a destructor.  */  if (DESTRUCTOR_NAME_P (DECL_ASSEMBLER_NAME (t))      && DECL_LANGUAGE (t) == lang_cplusplus)    {      OB_PUTC ('~');      dump_decl (name, 0);    }  else if (IDENTIFIER_TYPENAME_P (name))    {      /* This cannot use the hack that the operator's return	 type is stashed off of its name because it may be	 used for error reporting.  In the case of conflicting	 declarations, both will have the same name, yet	 the types will be different, hence the TREE_TYPE field	 of the first name will be clobbered by the second.  */      OB_PUTS ("operator ");      dump_type (TREE_TYPE (TREE_TYPE (t)), 0);    }  else if (IDENTIFIER_OPNAME_P (name))    {      char *name_string = operator_name_string (name);      OB_PUTS ("operator ");      OB_PUTCP (name_string);    }  else    dump_decl (name, 0);}static voiddump_char (c)     char c;{  switch (c)    {    case TARGET_NEWLINE:      OB_PUTS ("\\n");      break;    case TARGET_TAB:      OB_PUTS ("\\t");      break;    case TARGET_VT:      OB_PUTS ("\\v");      break;    case TARGET_BS:      OB_PUTS ("\\b");      break;    case TARGET_CR:      OB_PUTS ("\\r");      break;    case TARGET_FF:      OB_PUTS ("\\f");      break;    case TARGET_BELL:      OB_PUTS ("\\a");      break;    case '\\':      OB_PUTS ("\\\\");      break;    case '\'':      OB_PUTS ("\\'");      break;    case '\"':      OB_PUTS ("\\\"");      break;    default:      if (isprint (c))	OB_PUTC (c);      else	{	  sprintf (digit_buffer, "\\%03o", (int) c);	  OB_PUTCP (digit_buffer);	}    }}/* Print out a list of initializers (subr of dump_expr) */static voiddump_expr_list (l)     tree l;{  while (l)    {      dump_expr (TREE_VALUE (l), 0);      if (TREE_CHAIN (l))	OB_PUTC2 (',', ' ');      l = TREE_CHAIN (l);    }}/* Print out an expression */static voiddump_expr (t, nop)     tree t;     int nop;			/* suppress parens */{  switch (TREE_CODE (t))    {    case VAR_DECL:    case PARM_DECL:    case FIELD_DECL:    case CONST_DECL:    case FUNCTION_DECL:      dump_decl (t, -1);      break;    case INTEGER_CST:      {	tree type = TREE_TYPE (t);	my_friendly_assert (type != 0, 81);	/* If it's an enum, output its tag, rather than its value.  */	if (TREE_CODE (type) == ENUMERAL_TYPE)	  {	    char *p = enum_name_string (t, type);	    OB_PUTCP (p);	  }	else if (type == boolean_type_node)	  {	    if (t == boolean_false_node)	      OB_PUTS ("false");	    else if (t == boolean_true_node)	      OB_PUTS ("true");	    else	      my_friendly_abort (366);	  }	else if (type == char_type_node)	  {	    OB_PUTC ('\'');	    dump_char (TREE_INT_CST_LOW (t));	    OB_PUTC ('\'');	  }	else if (TREE_INT_CST_HIGH (t)		 != (TREE_INT_CST_LOW (t) >> (HOST_BITS_PER_WIDE_INT - 1)))	  {	    tree val = t;	    if (TREE_INT_CST_HIGH (val) < 0)	      {		OB_PUTC ('-');		val = build_int_2 (~TREE_INT_CST_LOW (val),				   -TREE_INT_CST_HIGH (val));	      }	    /* Would "%x%0*x" or "%x%*0x" get zero-padding on all	       systems?  */	    {	      static char format[10]; /* "%x%09999x\0" */	      if (!format[0])		sprintf (format, "%%x%%0%dx", HOST_BITS_PER_INT / 4);	      sprintf (digit_buffer, format, TREE_INT_CST_HIGH (val),		       TREE_INT_CST_LOW (val));	      OB_PUTCP (digit_buffer);	    }	  }	else	  OB_PUTI (TREE_INT_CST_LOW (t));      }      break;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -