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

📄 decl.c

📁 gcc-2.95.3 Linux下最常用的C编译器
💻 C
📖 第 1 页 / 共 5 页
字号:
	  if (TREE_CODE (x) != INTEGER_CST) abort ();	  p.value = x;	  p.decl = decl;	  if (p.decl == NULL_TREE)	    p.decl = TREE_VALUE (labellist);	  label_value_array[label_index++] = p;	}    }  if (errorcount == 0)    {      int limit;      qsort (label_value_array,	     label_index, sizeof (struct tree_pair), label_value_cmp);      limit = label_index - 1;      for (label_index = 0; label_index < limit; label_index++)	{	  if (tree_int_cst_equal (label_value_array[label_index].value, 				  label_value_array[label_index+1].value))	    {	      error_with_decl (label_value_array[label_index].decl,			       "variant label declared here...");	      error_with_decl (label_value_array[label_index+1].decl,			       "...is duplicated here");	    }	}    }  layout_type (utype);  return utype;}/* Convert a TREE_LIST of tag field names into a list of   field decls, found from FIXED_FIELDS, re-using the input list. */treelookup_tag_fields (tag_field_names, fixed_fields)     tree tag_field_names;     tree fixed_fields;{  tree list;  for (list = tag_field_names; list != NULL_TREE; list = TREE_CHAIN (list))    {      tree decl = fixed_fields;      for ( ; decl != NULL_TREE; decl = TREE_CHAIN (decl))	{	  if (DECL_NAME (decl) == TREE_VALUE (list))	    {	      TREE_VALUE (list) = decl;	      break;	    }	}      if (decl == NULL_TREE)	{	  error ("no field (yet) for tag %s",		 IDENTIFIER_POINTER (TREE_VALUE (list)));	  TREE_VALUE (list) = error_mark_node;	}    }  return tag_field_names;}/* If non-NULL, TAGFIELDS is the tag fields for this variant record.   BODY is a TREE_LIST of (optlabels, fixed fields).   If non-null, VARIANTELSE is a fixed field for the else part of the   variant record.  */treegrok_chill_variantdefs (tagfields, body, variantelse)     tree tagfields, body, variantelse;{  tree t;    t = make_chill_variants (tagfields, body, variantelse);  if (pass != 1)    t = layout_chill_variants (t);  return build_decl (FIELD_DECL, NULL_TREE, t);}/*  In pass 1, PARMS is a list of types (with attributes).  In pass 2, PARMS is a chain of PARM_DECLs.  */intstart_chill_function (label, rtype, parms, exceptlist, attrs)     tree label, rtype, parms, exceptlist, attrs;{  tree decl, fndecl, type, result_type, func_type;  int nested = current_function_decl != 0;  if (pass == 1)    {      func_type	= build_chill_function_type (rtype, parms, exceptlist, 0);      fndecl = build_decl (FUNCTION_DECL, label, func_type);      save_decl (fndecl);            /* Make the init_value nonzero so pushdecl knows this is not tentative.	 error_mark_node is replaced below (in poplevel) with the BLOCK.  */      DECL_INITIAL (fndecl) = error_mark_node;            DECL_EXTERNAL (fndecl) = 0;            /* This function exists in static storage.	 (This does not mean `static' in the C sense!)  */      TREE_STATIC (fndecl) = 1;      for (; attrs != NULL_TREE; attrs = TREE_CHAIN (attrs))	{	  if (TREE_VALUE (attrs) == ridpointers[RID_GENERAL])	    CH_DECL_GENERAL (fndecl) = 1;	  else if (TREE_VALUE (attrs) == ridpointers[RID_SIMPLE])	    CH_DECL_SIMPLE (fndecl) = 1;	  else if (TREE_VALUE (attrs) == ridpointers[RID_RECURSIVE])	    CH_DECL_RECURSIVE (fndecl) = 1;	  else if (TREE_VALUE (attrs) == ridpointers[RID_INLINE])	    DECL_INLINE (fndecl) = 1;	  else	    abort ();	}    }  else /* pass == 2 */    {      fndecl = get_next_decl ();       if (DECL_NAME (fndecl) != label)	abort ();           /* outta sync - got wrong decl */      func_type = TREE_TYPE (fndecl);      if (TYPE_RAISES_EXCEPTIONS (func_type) != NULL_TREE)	{	  /* In this case we have to add 2 parameters. 	     See build_chill_function_type (pass == 1). */	  tree arg;        	  arg = make_node (PARM_DECL);	  DECL_ASSEMBLER_NAME (arg) = DECL_NAME (arg) = get_identifier (CALLER_FILE);	  DECL_IGNORED_P (arg) = 1;	  parms = chainon (parms, arg);        	  arg = make_node (PARM_DECL);	  DECL_ASSEMBLER_NAME (arg) = DECL_NAME (arg) = get_identifier (CALLER_LINE);	  DECL_IGNORED_P (arg) = 1;	  parms = chainon (parms, arg);	}    }  current_function_decl = fndecl;  result_type = TREE_TYPE (func_type);  if (CH_TYPE_NONVALUE_P (result_type))    error ("non-value mode may only returned by LOC");  pushlevel (1); /* Push parameters. */  if (pass == 2)    {      DECL_ARGUMENTS (fndecl) = parms;      for (decl = DECL_ARGUMENTS (fndecl), type = TYPE_ARG_TYPES (func_type);	   decl != NULL_TREE;	   decl = TREE_CHAIN (decl), type = TREE_CHAIN (type))	{	  /* check here that modes with the non-value property (like	     BUFFER's, EVENT's, ASSOCIATION's, ACCESS's, or TEXT's) only	     gets passed by LOC */	  tree argtype = TREE_VALUE (type);	  tree argattr = TREE_PURPOSE (type);	  if (TREE_CODE (argtype) == REFERENCE_TYPE)	    argtype = TREE_TYPE (argtype);	  if (TREE_CODE (argtype) != ERROR_MARK &&	      TREE_CODE_CLASS (TREE_CODE (argtype)) != 't')	    {	      error_with_decl (decl, "mode of `%s' is not a mode");	      TREE_VALUE (type) = error_mark_node;	    }	  if (CH_TYPE_NONVALUE_P (argtype) &&	      argattr != ridpointers[(int) RID_LOC])	    error_with_decl (decl, "`%s' may only be passed by LOC");	  TREE_TYPE (decl) = TREE_VALUE (type);	  DECL_ARG_TYPE (decl) = TREE_TYPE (decl);	  DECL_CONTEXT (decl) = fndecl;	  TREE_READONLY (decl) = TYPE_READONLY (argtype);	  layout_decl (decl, 0);	}      pushdecllist (DECL_ARGUMENTS (fndecl), 0);      DECL_RESULT (current_function_decl)	= build_decl (RESULT_DECL, NULL_TREE, result_type);#if 0      /* Write a record describing this function definition to the prototypes	 file (if requested).  */      gen_aux_info_record (fndecl, 1, 0, prototype);#endif      if (fndecl != global_function_decl || seen_action)	{	  /* Initialize the RTL code for the function.  */	  init_function_start (fndecl, input_filename, lineno);	  /* Set up parameters and prepare for return, for the function.  */	  expand_function_start (fndecl, 0);	}      if (!nested)	/* Allocate further tree nodes temporarily during compilation	   of this function only.  */	temporary_allocation ();      /* If this fcn was already referenced via a block-scope `extern' decl (or	 an implicit decl), propagate certain information about the usage. */      if (TREE_ADDRESSABLE (DECL_ASSEMBLER_NAME (current_function_decl)))	TREE_ADDRESSABLE (current_function_decl) = 1;    }        /* Z.200 requires that formal parameter names be defined in     the same block as the procedure body.     We could do this by keeping boths sets of DECLs in the same     scope, but we would have to be careful to not merge the     two chains (e.g. DECL_ARGUEMENTS musr not contains locals).     Instead, we just make sure they have the same nesting_level. */  current_nesting_level--;  pushlevel (1); /* Push local variables. */  if (pass == 2 && (fndecl != global_function_decl || seen_action))    {      /* generate label for possible 'exit' */      expand_start_bindings (1);      result_never_set = 1;    }  if (TREE_CODE (result_type) == VOID_TYPE)    chill_result_decl = NULL_TREE;  else    {      /* We use the same name as the keyword.	 This makes it easy to print and change the RESULT from gdb. */      char *result_str = (ignore_case || ! special_UC) ? "result" : "RESULT";      if (pass == 2 && TREE_CODE (result_type) == ERROR_MARK)	TREE_TYPE (current_scope->remembered_decls) = result_type;      chill_result_decl = do_decl (get_identifier (result_str),				   result_type, 0, 0, 0, 0);      DECL_CONTEXT (chill_result_decl) = fndecl;    }  return 1;}/* For checking purpose added pname as new argument   MW Wed Oct 14 14:22:10 1992 */voidfinish_chill_function (){  register tree fndecl = current_function_decl;  tree outer_function = decl_function_context (fndecl);  int nested;  if (outer_function == NULL_TREE && fndecl != global_function_decl)    outer_function = global_function_decl;  nested = current_function_decl != global_function_decl;  if (pass == 2 && (fndecl != global_function_decl || seen_action))    expand_end_bindings (getdecls (), 1, 0);      /* pop out of function */  poplevel (1, 1, 0);  current_nesting_level++;  /* pop out of its parameters */  poplevel (1, 0, 1);  if (pass == 2)    {      /*  TREE_READONLY (fndecl) = 1;	  This caused &foo to be of type ptr-to-const-function which	  then got a warning when stored in a ptr-to-function variable. */      BLOCK_SUPERCONTEXT (DECL_INITIAL (fndecl)) = fndecl;      /* Must mark the RESULT_DECL as being in this function.  */      DECL_CONTEXT (DECL_RESULT (fndecl)) = fndecl;      if (fndecl != global_function_decl || seen_action)	{	  /* Generate rtl for function exit.  */	  expand_function_end (input_filename, lineno, 0);	  /* So we can tell if jump_optimize sets it to 1.  */	  can_reach_end = 0;	  /* Run the optimizers and output assembler code for this function. */	  rest_of_compilation (fndecl);	}      if (DECL_SAVED_INSNS (fndecl) == 0 && ! nested)	{	  /* Stop pointing to the local nodes about to be freed.  */	  /* But DECL_INITIAL must remain nonzero so we know this	     was an actual function definition.  */	  /* For a nested function, this is done in pop_chill_function_context.  */	  DECL_INITIAL (fndecl) = error_mark_node;	  DECL_ARGUMENTS (fndecl) = 0;	}    }  current_function_decl = outer_function;}/* process SEIZE *//* Points to the head of the _DECLs read from seize files.  */#if 0static tree seized_decls;static tree processed_seize_files = 0;#endifvoidchill_seize (old_prefix, new_prefix, postfix)     tree old_prefix, new_prefix, postfix;{  if (pass == 1)    {      tree decl = build_alias_decl (old_prefix, new_prefix, postfix);      DECL_SEIZEFILE(decl) = use_seizefile_name;      save_decl (decl);    }  else /* pass == 2 */    {      /* Do nothing - get_next_decl automatically ignores ALIAS_DECLs */    }}#if 0/* * output a debug dump of a scope structure */voiddebug_scope (sp)     struct scope *sp;{  if (sp == (struct scope *)NULL)    {      fprintf (stderr, "null scope ptr\n");      return;    }  fprintf (stderr, "enclosing 0x%x ",           sp->enclosing);  fprintf (stderr, "next 0x%x ",                sp->next);   fprintf (stderr, "remembered_decls 0x%x ",    sp->remembered_decls);  fprintf (stderr, "decls 0x%x\n",              sp->decls);   fprintf (stderr, "shadowed 0x%x ",            sp->shadowed);   fprintf (stderr, "blocks 0x%x ",              sp->blocks);   fprintf (stderr, "this_block 0x%x ",          sp->this_block);   fprintf (stderr, "level_chain 0x%x\n",        sp->level_chain);  fprintf (stderr, "module_flag %c ",           sp->module_flag ? 'T' : 'F');  fprintf (stderr, "first_child_module 0x%x ",  sp->first_child_module);  fprintf (stderr, "next_sibling_module 0x%x\n", sp->next_sibling_module);  if (sp->remembered_decls != NULL_TREE)    {      tree temp;      fprintf (stderr, "remembered_decl chain:\n");      for (temp = sp->remembered_decls; temp; temp = TREE_CHAIN (temp))	debug_tree (temp);    }}#endifstatic voidsave_decl (decl)     tree decl;{  if (current_function_decl != global_function_decl)    DECL_CONTEXT (decl) = current_function_decl;  TREE_CHAIN (decl) = current_scope->remembered_decls;  current_scope->remembered_decls = decl;#if 0  fprintf (stderr, "\n\nsave_decl 0x%x\n", decl);  debug_scope (current_scope);  /* ************* */#endif  set_nesting_level (decl, current_nesting_level);}static treeget_next_decl (){  tree decl;  do    {      decl = current_scope->remembered_decls;      current_scope->remembered_decls = TREE_CHAIN (decl);      /* We ignore ALIAS_DECLs, because push_scope_decls	 can convert a single ALIAS_DECL representing 'SEIZE ALL'	 into one ALIAS_DECL for each seizeable name.	 This means we lose the nice one-to-one mapping         between pass 1 decls and pass 2 decls.	 (Perhaps ALIAS_DECLs should not be on the remembered_decls list.) */    } while (decl && TREE_CODE (decl) == ALIAS_DECL);  return decl;}/* At the end of pass 1, we reverse the chronological chain of scopes. */voidswitch_to_pass_2 (){#if 0  extern int errorcount, sorrycount;#endif  if (current_scope != &builtin_scope)    abort ();  last_scope = &builtin_scope;  builtin_scope.remembered_decls = nreverse (builtin_scope.remembered_decls);  write_grant_file ();#if 0  if (errorcount || sorrycount)    exit (FATAL_EXIT_CODE);  else#endif  if (grant_only_flag)    exit (SUCCESS_EXIT_CODE);  pass = 2;  module_number = 0;  next_module = &first_module;}/* * Called during pass 2, when we're processing actions, to * generate a temporary variable.  These don't need satisfying * because they're compiler-generated and always declared * before they're used. */treedecl_temp1 (name, type, opt_static, opt_init, 	    opt_external, opt_public)     tree name, type;     int  opt_static;     tree opt_init;     int  opt_external, opt_public;{  int orig_pass = pass;           /* be cautious */  tree mydecl;  pass = 1;  mydecl = do_decl (name, type, opt_static, opt_sta

⌨️ 快捷键说明

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