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

📄 c-decl.c

📁 这是完整的gcc源代码
💻 C
📖 第 1 页 / 共 5 页
字号:
			   tree_cons (NULL_TREE,				      long_integer_type_node, endlink));  void_ftype_ptr_ptr_int    = build_function_type (void_type_node,			   tree_cons (NULL_TREE, ptr_type_node,				      tree_cons (NULL_TREE, ptr_type_node,						 tree_cons (NULL_TREE,							    integer_type_node,							    endlink))));  int_ftype_ptr_ptr_int    = build_function_type (integer_type_node,			   tree_cons (NULL_TREE, ptr_type_node,				      tree_cons (NULL_TREE, ptr_type_node,						 tree_cons (NULL_TREE,							    integer_type_node,							    endlink))));  void_ftype_ptr_int_int    = build_function_type (void_type_node,			   tree_cons (NULL_TREE, ptr_type_node,				      tree_cons (NULL_TREE, integer_type_node,						 tree_cons (NULL_TREE,							    integer_type_node,							    endlink))));  builtin_function ("__builtin_alloca",		    build_function_type (ptr_type_node,					 tree_cons (NULL_TREE,						    integer_type_node,						    endlink)),		    BUILT_IN_ALLOCA);  builtin_function ("__builtin_abs", int_ftype_int, BUILT_IN_ABS);  builtin_function ("__builtin_fabs", double_ftype_double, BUILT_IN_FABS);  builtin_function ("__builtin_labs", long_ftype_long, BUILT_IN_LABS);  builtin_function ("__builtin_ffs", int_ftype_int, BUILT_IN_FFS);  builtin_function ("__builtin_saveregs", default_function_type,		    BUILT_IN_SAVEREGS);  builtin_function ("__builtin_classify_type", default_function_type,		    BUILT_IN_CLASSIFY_TYPE);  builtin_function ("__builtin_next_arg",		    build_function_type (ptr_type_node, endlink),		    BUILT_IN_NEXT_ARG);#if 0  /* Support for these has not been written in either expand_builtin     or build_function_call.  */  builtin_function ("__builtin_div", default_ftype, BUILT_IN_DIV);  builtin_function ("__builtin_ldiv", default_ftype, BUILT_IN_LDIV);  builtin_function ("__builtin_ffloor", double_ftype_double, BUILT_IN_FFLOOR);  builtin_function ("__builtin_fceil", double_ftype_double, BUILT_IN_FCEIL);  builtin_function ("__builtin_fmod", double_ftype_double_double, BUILT_IN_FMOD);  builtin_function ("__builtin_frem", double_ftype_double_double, BUILT_IN_FREM);  builtin_function ("__builtin_memcpy", void_ftype_ptr_ptr_int, BUILT_IN_MEMCPY);  builtin_function ("__builtin_memcmp", int_ftype_ptr_ptr_int, BUILT_IN_MEMCMP);  builtin_function ("__builtin_memset", void_ftype_ptr_int_int, BUILT_IN_MEMSET);  builtin_function ("__builtin_fsqrt", double_ftype_double, BUILT_IN_FSQRT);  builtin_function ("__builtin_getexp", double_ftype_double, BUILT_IN_GETEXP);  builtin_function ("__builtin_getman", double_ftype_double, BUILT_IN_GETMAN);#endif  void_list_node = tree_cons (NULL_TREE, void_type_node, NULL_TREE);  start_identifier_warnings ();}/* Make a definition for a builtin function named NAME and whose data type   is TYPE.  TYPE should be a function type with argument types.   FUNCTION_CODE tells later passes how to compile calls to this function.   See tree.h for its possible values.  */static voidbuiltin_function (name, type, function_code)     char *name;     tree type;     enum built_in_function function_code;{  tree decl = build_decl (FUNCTION_DECL, get_identifier (name), type);  TREE_EXTERNAL (decl) = 1;  TREE_PUBLIC (decl) = 1;  make_decl_rtl (decl, 0, 1);  pushdecl (decl);  DECL_SET_FUNCTION_CODE (decl, function_code);}/* Called when a declaration is seen that contains no names to declare.   If its type is a reference to a structure, union or enum inherited   from a containing scope, shadow that tag name for the current scope   with a forward reference.   If its type defines a new named structure or union   or defines an enum, it is valid but we need not do anything here.   Otherwise, it is an error.  */voidshadow_tag (declspecs)     tree declspecs;{  int found_tag = 0;  int warned = 0;  register tree link;  for (link = declspecs; link; link = TREE_CHAIN (link))    {      register tree value = TREE_VALUE (link);      register enum tree_code code = TREE_CODE (value);      int ok = 0;      if (code == RECORD_TYPE || code == UNION_TYPE || code == ENUMERAL_TYPE)	/* Used to test also that TYPE_SIZE (value) != 0.	   That caused warning for `struct foo;' at top level in the file.  */	{	  register tree name = lookup_tag_reverse (value);	  register tree t = lookup_tag (code, name, current_binding_level, 1);	  if (t == 0)	    {	      t = make_node (code);	      pushtag (name, t);	      ok = 1;	    }	  else if (name != 0 || code == ENUMERAL_TYPE)	    ok = 1;	}      if (ok)	found_tag++;      else	{	  if (!warned)	    warning ("useless keyword or type name in declaration");	  warned = 1;	}    }  if (!warned)    {      if (found_tag > 1)	warning ("multiple types in one declaration");      if (found_tag == 0)	warning ("empty declaration");    }}/* Decode a "typename", such as "int **", returning a ..._TYPE node.  */treegroktypename (typename)     tree typename;{  if (TREE_CODE (typename) != TREE_LIST)    return typename;  return grokdeclarator (TREE_VALUE (typename),			 TREE_PURPOSE (typename),			 TYPENAME, 0);}/* Decode a declarator in an ordinary declaration or data definition.   This is called as soon as the type information and variable name   have been parsed, before parsing the initializer if any.   Here we create the ..._DECL node, fill in its type,   and put it on the list of decls for the current context.   The ..._DECL node is returned as the value.   Exception: for arrays where the length is not specified,   the type is left null, to be filled in by `finish_decl'.   Function definitions do not come here; they go to start_function   instead.  However, external and forward declarations of functions   do go through here.  Structure field declarations are done by   grokfield and not through here.  *//* Set this to zero to debug not using the temporary obstack   to parse initializers.  */int debug_temp_inits = 1;treestart_decl (declarator, declspecs, initialized)     tree declspecs, declarator;     int initialized;{  register tree decl = grokdeclarator (declarator, declspecs,				       NORMAL, initialized);  register tree tem;  int init_written = initialized;  if (initialized)    /* Is it valid for this decl to have an initializer at all?       If not, set INITIALIZED to zero, which will indirectly       tell `finish_decl' to ignore the initializer once it is parsed.  */    switch (TREE_CODE (decl))      {      case TYPE_DECL:	/* typedef foo = bar  means give foo the same type as bar.	   We haven't parsed bar yet, so `finish_decl' will fix that up.	   Any other case of an initialization in a TYPE_DECL is an error.  */	if (pedantic || list_length (declspecs) > 1)	  {	    error ("typedef `%s' is initialized",		   IDENTIFIER_POINTER (DECL_NAME (decl)));	    initialized = 0;	  }	break;      case FUNCTION_DECL:	error ("function `%s' is initialized like a variable",	       IDENTIFIER_POINTER (DECL_NAME (decl)));	initialized = 0;	break;      default:	/* Don't allow initializations for incomplete types	   except for arrays which might be completed by the initialization.  */	if (TYPE_SIZE (TREE_TYPE (decl)) != 0)	  ;			/* A complete type is ok.  */	else if (TREE_CODE (TREE_TYPE (decl)) != ARRAY_TYPE)	  {	    error ("variable `%s' has initializer but incomplete type",		   IDENTIFIER_POINTER (DECL_NAME (decl)));	    initialized = 0;	  }	else if (TYPE_SIZE (TREE_TYPE (TREE_TYPE (decl))) == 0)	  {	    error ("elements of array `%s' have incomplete type",		   IDENTIFIER_POINTER (DECL_NAME (decl)));	    initialized = 0;	  }      }  if (initialized)    {#if 0  /* Seems redundant.  */      if (current_binding_level != global_binding_level	  && TREE_EXTERNAL (decl)	  && TREE_CODE (decl) != FUNCTION_DECL)	warning ("declaration of `%s' has `extern' and is initialized",		 IDENTIFIER_POINTER (DECL_NAME (decl)));#endif      TREE_EXTERNAL (decl) = 0;      if (current_binding_level == global_binding_level)	TREE_STATIC (decl) = 1;      /* Tell `pushdecl' this is an initialized decl	 even though we don't yet have the initializer expression.	 Also tell `finish_decl' it may store the real initializer.  */      DECL_INITIAL (decl) = error_mark_node;    }  /* Add this decl to the current binding level.     TEM may equal DECL or it may be a previous decl of the same name.  */  tem = pushdecl (decl);  /* For a local variable, define the RTL now.  */  if (current_binding_level != global_binding_level      /* But not if this is a duplicate decl	 and we preserved the rtl from the previous one	 (which may or may not happen).  */      && DECL_RTL (tem) == 0)    {      if (TYPE_SIZE (TREE_TYPE (tem)) != 0)	expand_decl (tem, NULL_TREE);      else if (TREE_CODE (TREE_TYPE (tem)) == ARRAY_TYPE	       && DECL_INITIAL (tem) != 0)	expand_decl (tem, NULL_TREE);    }  if (init_written)    {      /* When parsing and digesting the initializer,	 use temporary storage.  Do this even if we will ignore the value.  */      if (current_binding_level == global_binding_level && debug_temp_inits)	temporary_allocation ();    }  return tem;}/* Finish processing of a declaration;   install its line number and initial value.   If the length of an array type is not known before,   it must be determined now, from the initial value, or it is an error.  */voidfinish_decl (decl, init, asmspec_tree)     tree decl, init;     tree asmspec_tree;{  register tree type = TREE_TYPE (decl);  int was_incomplete = (DECL_SIZE (decl) == 0);  int temporary = allocation_temporary_p ();  char *asmspec = 0;  if (asmspec_tree)    asmspec = TREE_STRING_POINTER (asmspec_tree);  /* If `start_decl' didn't like having an initialization, ignore it now.  */  if (init != 0 && DECL_INITIAL (decl) == 0)    init = 0;  if (init)    {      if (TREE_CODE (decl) != TYPE_DECL)	store_init_value (decl, init);      else	{	  /* typedef foo = bar; store the type of bar as the type of foo.  */	  TREE_TYPE (decl) = TREE_TYPE (init);	  DECL_INITIAL (decl) = init = 0;	}    }  /* For top-level declaration, the initial value was read in     the temporary obstack.  MAXINDEX, rtl, etc. to be made below     must go in the permanent obstack; but don't discard the     temporary data yet.  */  if (current_binding_level == global_binding_level && temporary)    end_temporary_allocation ();  /* Deduce size of array from initialization, if not already known */  if (TREE_CODE (type) == ARRAY_TYPE      && TYPE_DOMAIN (type) == 0      && TREE_CODE (decl) != TYPE_DECL)    {#if 0      int do_default = ! ((!pedantic && TREE_STATIC (decl))			  || TREE_EXTERNAL (decl));#endif      int do_default	= (TREE_STATIC (decl)	   /* Even if pedantic, an external linkage array	      may have incomplete type at first.  */	   ? pedantic && !TREE_PUBLIC (decl)	   : !TREE_EXTERNAL (decl));      int failure	= complete_array_type (type, DECL_INITIAL (decl), do_default);      if (failure == 1)	error_with_decl (decl, "initializer fails to determine size of `%s'");      if (failure == 2)	{	  if (do_default)	    {	      if (! TREE_PUBLIC (decl))		error_with_decl (decl, "array size missing in `%s'");	    }	  else if (!pedantic && TREE_STATIC (decl))	    TREE_EXTERNAL (decl) = 1;	}      if (pedantic && TYPE_DOMAIN (type) != 0	  && tree_int_cst_lt (TYPE_MAX_VALUE (TYPE_DOMAIN (type)),			      integer_zero_node))	error_with_decl (decl, "zero-size array `%s'");      layout_decl (decl, 0);    }  if (TREE_CODE (decl) == VAR_DECL)    {      if (TREE_STATIC (decl) && DECL_SIZE (decl) == 0)	{	  /* A static variable with an incomplete type:	     that is an error if it is initialized or `static'.	     Otherwise, let it through, but if it is not `extern'	     then it may cause an error message later.  */	  if (! (TREE_PUBLIC (decl) && DECL_INITIAL (decl) == 0))	    error_with_decl (decl, "storage size of `%s' isn't known");	}      else if (!TREE_EXTERNAL (decl) && DECL_SIZE (decl) == 0)	{	  /* An automatic variable with an incomplete type:	     that is an error.  */	  error_with_decl (decl, "storage size of `%s' isn't known");	  TREE_TYPE (decl) = error_mark_node;	}      if ((TREE_EXTERNAL (decl) || TREE_STATIC (decl))	  && DECL_SIZE (decl) != 0 && ! TREE_LITERAL (DECL_SIZE (decl)))	error_with_decl (decl, "storage size of `%s' isn't constant");    }  /* Output the assembler code and/or RTL code for variables and functions,     unless the type is an undefined structure or union.     If not, it will get done when the type is completed.  */  if (TREE_CODE (decl) == VAR_DECL || TREE_CODE (decl) == FUNCTION_DECL)    {      if (flag_traditional && allocation_temporary_p ())	{	  end_temporary_allocation ();	  rest_of_decl_compilation (decl, asmspec,				    current_binding_level == global_binding_level,				    0);	  resume_temporary_allocation ();	}      else	rest_of_decl_compilation (decl, asmspec,				  current_binding_level == global_binding_level,				  0);      if (current_binding_level != global_binding_level)	{	  /* Recompute the RTL of a local array now	     if it used to be an incomplete type.  */	  if (was_incomplete	      && ! TREE_STATIC (decl) && ! TREE_EXTERNAL (decl))	    {	      /* If we used it already as memory, it must stay in memory.  */	      TREE_ADDRESSABLE (decl) = TREE_USED (decl);	      /* If it's still incomplete now, no init will save it.  */	      if (DECL_SIZE (decl) == 0)		DECL_INITIAL (decl) = 0;	      expand_decl (decl, NULL_TREE);	  

⌨️ 快捷键说明

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