GCC Wikia
Advertisement

このページを編集する際は,編集に関する方針に従ってください.[]

概要[]

引数[]

  • const tree node
  • const char *file
  • int line
  • const char *function
  • ...

実装[]

5960 #if defined ENABLE_TREE_CHECKING && (GCC_VERSION >= 2007)
5961 
 5962 /* Complain that the tree code of NODE does not match the expected 0
 5963    terminated list of trailing codes. The trailing code list can be
 5964    empty, for a more vague error message.  FILE, LINE, and FUNCTION
 5965    are of the caller.  */
5966 
5967 void
5968 tree_check_failed (const tree node, const char *file,
5969                    int line, const char *function, ...)
5970 {
5971   va_list args;
5972   char *buffer;
5973   unsigned length = 0;
5974   int code;
5975 

*tree codeの名前を長さの合計を得る

5976   va_start (args, function);
5977   while ((code = va_arg (args, int)))
5978     length += 4 + strlen (tree_code_name[code]);
5979   va_end (args);

~
*allocaは__builtin_alloca
**gcc-4.1.0/include/libiberty.h
***こっちを利用しているようだ
**gcc-4.1.0/gcc/tsystem.h

5980   if (length)
5981     {
5982       va_start (args, function);
5983       length += strlen ("expected ");
5984       buffer = alloca (length);
5985       length = 0;

~
*連結していく

5986       while ((code = va_arg (args, int)))
5987         {
5988           const char *prefix = length ? " or " : "expected ";
5989           
5990           strcpy (buffer + length, prefix);
5991           length += strlen (prefix);
5992           strcpy (buffer + length, tree_code_name[code]);
5993           length += strlen (tree_code_name[code]);
5994         }
5995       va_end (args);
5996     }

~

5997   else
5998     buffer = (char *)"unexpected node";
5999 

*実際に出力

6000   internal_error ("tree check: %s, have %s in %s, at %s:%d",
6001                   buffer, tree_code_name[[[TREE_CODE]] (node)],
6002                   function, trim_filename (file), line);
6003 }

~

6117 #endif /* ENABLE_TREE_CHECKING */


リンク元

Advertisement