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

📄 decl.c

📁 gcc-2.95.3 Linux下最常用的C编译器
💻 C
📖 第 1 页 / 共 5 页
字号:
/* Process declarations and variables for C compiler.   Copyright (C) 1988, 92-98, 1999 Free Software Foundation, Inc.   Contributed by Michael Tiemann (tiemann@cygnus.com)This file is part of GNU CC.GNU CC is free software; you can redistribute it and/or modifyit under the terms of the GNU General Public License as published bythe Free Software Foundation; either version 2, or (at your option)any later version.GNU CC is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See theGNU General Public License for more details.You should have received a copy of the GNU General Public Licensealong with GNU CC; see the file COPYING.  If not, write tothe Free Software Foundation, 59 Temple Place - Suite 330,Boston, MA 02111-1307, USA.  *//* Process declarations and symbol lookup for C front end.   Also constructs types; the standard scalar types at initialization,   and structure, union, array and enum types when they are declared.  *//* ??? not all decl nodes are given the most useful possible   line numbers.  For example, the CONST_DECLs for enum values.  */#include "config.h"#include "system.h"#include "tree.h"#include "rtl.h"#include "flags.h"#include "cp-tree.h"#include "decl.h"#include "lex.h"#include <signal.h>#include "obstack.h"#include "defaults.h"#include "output.h"#include "except.h"#include "toplev.h"#include "../hash.h"#define obstack_chunk_alloc xmalloc#define obstack_chunk_free freeextern tree builtin_return_address_fndecl;extern struct obstack permanent_obstack;extern struct obstack* saveable_obstack;extern int current_class_depth;extern tree static_ctors, static_dtors;extern int static_labelno;extern tree current_namespace;extern tree global_namespace;extern void (*print_error_function) PROTO((char *));extern int (*valid_lang_attribute) PROTO ((tree, tree, tree, tree));/* Obstack used for remembering local class declarations (like   enums and static (const) members.  */#include "stack.h"struct obstack decl_obstack;static struct stack_level *decl_stack;#ifndef CHAR_TYPE_SIZE#define CHAR_TYPE_SIZE BITS_PER_UNIT#endif#ifndef SHORT_TYPE_SIZE#define SHORT_TYPE_SIZE (BITS_PER_UNIT * MIN ((UNITS_PER_WORD + 1) / 2, 2))#endif#ifndef INT_TYPE_SIZE#define INT_TYPE_SIZE BITS_PER_WORD#endif#ifndef LONG_TYPE_SIZE#define LONG_TYPE_SIZE BITS_PER_WORD#endif#ifndef LONG_LONG_TYPE_SIZE#define LONG_LONG_TYPE_SIZE (BITS_PER_WORD * 2)#endif#ifndef WCHAR_UNSIGNED#define WCHAR_UNSIGNED 0#endif#ifndef FLOAT_TYPE_SIZE#define FLOAT_TYPE_SIZE BITS_PER_WORD#endif#ifndef DOUBLE_TYPE_SIZE#define DOUBLE_TYPE_SIZE (BITS_PER_WORD * 2)#endif#ifndef LONG_DOUBLE_TYPE_SIZE#define LONG_DOUBLE_TYPE_SIZE (BITS_PER_WORD * 2)#endif#ifndef BOOL_TYPE_SIZE#ifdef SLOW_BYTE_ACCESS#define BOOL_TYPE_SIZE ((SLOW_BYTE_ACCESS) ? (POINTER_SIZE) : (CHAR_TYPE_SIZE))#else#define BOOL_TYPE_SIZE CHAR_TYPE_SIZE#endif#endif/* We let tm.h override the types used here, to handle trivial differences   such as the choice of unsigned int or long unsigned int for size_t.   When machines start needing nontrivial differences in the size type,   it would be best to do something here to figure out automatically   from other information what type to use.  */#ifndef SIZE_TYPE#define SIZE_TYPE "long unsigned int"#endif#ifndef PTRDIFF_TYPE#define PTRDIFF_TYPE "long int"#endif#ifndef WCHAR_TYPE#define WCHAR_TYPE "int"#endifstatic tree grokparms				PROTO((tree, int));static tree lookup_nested_type			PROTO((tree, tree));static const char *redeclaration_error_message	PROTO((tree, tree));static struct stack_level *push_decl_level PROTO((struct stack_level *,						  struct obstack *));static void push_binding_level PROTO((struct binding_level *, int,				      int));static void pop_binding_level PROTO((void));static void suspend_binding_level PROTO((void));static void resume_binding_level PROTO((struct binding_level *));static struct binding_level *make_binding_level PROTO((void));static void declare_namespace_level PROTO((void));static void signal_catch PROTO((int)) ATTRIBUTE_NORETURN;static void storedecls PROTO((tree));static void require_complete_types_for_parms PROTO((tree));static void push_overloaded_decl_1 PROTO((tree));static int ambi_op_p PROTO((tree));static int unary_op_p PROTO((tree));static tree store_bindings PROTO((tree, tree));static tree lookup_tag_reverse PROTO((tree, tree));static tree obscure_complex_init PROTO((tree, tree));static tree maybe_build_cleanup_1 PROTO((tree, tree));static tree lookup_name_real PROTO((tree, int, int, int));static void warn_extern_redeclared_static PROTO((tree, tree));static void grok_reference_init PROTO((tree, tree, tree));static tree grokfndecl PROTO((tree, tree, tree, tree, int,			      enum overload_flags, tree,			      tree, int, int, int, int, int, int, tree));static tree grokvardecl PROTO((tree, tree, RID_BIT_TYPE *, int, int, tree));static tree lookup_tag PROTO((enum tree_code, tree,			      struct binding_level *, int));static void set_identifier_type_value_with_scope	PROTO((tree, tree, struct binding_level *));static void record_builtin_type PROTO((enum rid, const char *, tree));static void record_unknown_type PROTO((tree, const char *));static int member_function_or_else PROTO((tree, tree, const char *));static void bad_specifiers PROTO((tree, const char *, int, int, int, int,				  int));static void lang_print_error_function PROTO((char *));static tree maybe_process_template_type_declaration PROTO((tree, int, struct binding_level*));static void check_for_uninitialized_const_var PROTO((tree));static unsigned long typename_hash PROTO((hash_table_key));static boolean typename_compare PROTO((hash_table_key, hash_table_key));static void push_binding PROTO((tree, tree, struct binding_level*));static int add_binding PROTO((tree, tree));static void pop_binding PROTO((tree, tree));static tree local_variable_p PROTO((tree));static tree find_binding PROTO((tree, tree));static tree select_decl PROTO((tree, int));static tree unqualified_namespace_lookup PROTO((tree, int));static int lookup_flags PROTO((int, int));static tree qualify_lookup PROTO((tree, int));static tree record_builtin_java_type PROTO((const char *, int));static const char *tag_name PROTO((enum tag_types code));static void find_class_binding_level PROTO((void));static struct binding_level *innermost_nonclass_level PROTO((void));static void finish_dtor PROTO((void));static void finish_ctor PROTO((int));static tree poplevel_class PROTO((void));static void warn_about_implicit_typename_lookup PROTO((tree, tree));static int walk_namespaces_r PROTO((tree, walk_namespaces_fn, void *));static int walk_globals_r PROTO((tree, void *));#if defined (DEBUG_CP_BINDING_LEVELS)static void indent PROTO((void));#endif/* A node which has tree code ERROR_MARK, and whose type is itself.   All erroneous expressions are replaced with this node.  All functions   that accept nodes as arguments should avoid generating error messages   if this node is one of the arguments, since it is undesirable to get   multiple error messages from one error in the input.  */tree error_mark_node;/* Erroneous argument lists can use this *IFF* they do not modify it.  */tree error_mark_list;/* INTEGER_TYPE and REAL_TYPE nodes for the standard data types */tree short_integer_type_node;tree integer_type_node;tree long_integer_type_node;tree long_long_integer_type_node;tree short_unsigned_type_node;tree unsigned_type_node;tree long_unsigned_type_node;tree long_long_unsigned_type_node;tree ptrdiff_type_node;tree unsigned_char_type_node;tree signed_char_type_node;tree char_type_node;tree wchar_type_node;tree signed_wchar_type_node;tree unsigned_wchar_type_node;tree wchar_decl_node;tree float_type_node;tree double_type_node;tree long_double_type_node;tree complex_integer_type_node;tree complex_float_type_node;tree complex_double_type_node;tree complex_long_double_type_node;tree intQI_type_node;tree intHI_type_node;tree intSI_type_node;tree intDI_type_node;#if HOST_BITS_PER_WIDE_INT >= 64tree intTI_type_node;#endiftree unsigned_intQI_type_node;tree unsigned_intHI_type_node;tree unsigned_intSI_type_node;tree unsigned_intDI_type_node;#if HOST_BITS_PER_WIDE_INT >= 64tree unsigned_intTI_type_node;#endiftree java_byte_type_node;tree java_short_type_node;tree java_int_type_node;tree java_long_type_node;tree java_float_type_node;tree java_double_type_node;tree java_char_type_node;tree java_boolean_type_node;/* A VOID_TYPE node, and the same, packaged in a TREE_LIST.  */tree void_type_node, void_list_node;tree void_zero_node;/* Nodes for types `void *' and `const void *'.  */tree ptr_type_node;tree const_ptr_type_node;/* Nodes for types `char *' and `const char *'.  */tree string_type_node, const_string_type_node;/* Type `char[256]' or something like it.   Used when an array of char is needed and the size is irrelevant.  */tree char_array_type_node;/* Type `int[256]' or something like it.   Used when an array of int needed and the size is irrelevant.  */tree int_array_type_node;/* Type `wchar_t[256]' or something like it.   Used when a wide string literal is created.  */tree wchar_array_type_node;/* The bool data type, and constants */tree boolean_type_node, boolean_true_node, boolean_false_node;/* Type `int ()' -- used for implicit declaration of functions.  */tree default_function_type;/* Function types `double (double)' and `double (double, double)', etc.  */static tree double_ftype_double, double_ftype_double_double;static tree int_ftype_int, long_ftype_long;static tree float_ftype_float;static tree ldouble_ftype_ldouble;/* Function type `int (const void *, const void *, size_t)' */static tree int_ftype_cptr_cptr_sizet;/* C++ extensions */tree vtable_entry_type;tree delta_type_node;#if 0/* Old rtti stuff.  */tree __baselist_desc_type_node;tree __i_desc_type_node, __m_desc_type_node;tree __t_desc_array_type, __i_desc_array_type, __m_desc_array_type;#endiftree __t_desc_type_node;#if 0tree __tp_desc_type_node;#endiftree __access_mode_type_node;tree __bltn_desc_type_node, __user_desc_type_node, __class_desc_type_node;tree __ptr_desc_type_node, __attr_desc_type_node, __func_desc_type_node;tree __ptmf_desc_type_node, __ptmd_desc_type_node;#if 0/* Not needed yet?  May be needed one day?  */tree __bltn_desc_array_type, __user_desc_array_type, __class_desc_array_type;tree __ptr_desc_array_type, __attr_dec_array_type, __func_desc_array_type;tree __ptmf_desc_array_type, __ptmd_desc_array_type;#endif/* This is the identifier __vlist. */tree vlist_identifier;/* This is the type _Vlist = vtable_entry_type**. */tree vlist_type_node;/* A null pointer of type _Vlist. */tree vlist_zero_node;/* Indicates that there is a type value in some namespace, although   that is not necessarily in scope at the moment. */static tree global_type_node;tree class_star_type_node;tree class_type_node, record_type_node, union_type_node, enum_type_node;tree unknown_type_node;tree opaque_type_node, signature_type_node;tree sigtable_entry_type;/* Array type `vtable_entry_type[]' */tree vtbl_type_node;tree vtbl_ptr_type_node;/* namespace std */tree std_node;int in_std = 0;/* Expect only namespace names now. */static int only_namespace_names;/* In a destructor, the point at which all derived class destroying   has been done, just before any base class destroying will be done.  */tree dtor_label;/* In a destructor, the last insn emitted after the start of the   function and the parms.  */static rtx last_dtor_insn;/* In a constructor, the last insn emitted after the start of the   function and the parms, the exception specification and any   function-try-block.  The constructor initializers are emitted after   this insn.  */static rtx last_parm_cleanup_insn;/* In a constructor, the point at which we are ready to return   the pointer to the initialized object.  */tree ctor_label;/* A FUNCTION_DECL which can call `abort'.  Not necessarily the   one that the user will declare, but sufficient to be called   by routines that want to abort the program.  */tree abort_fndecl;/* A FUNCTION_DECL for the default `::operator delete'.  */tree global_delete_fndecl;extern rtx cleanup_label, return_label;/* If original DECL_RESULT of current function was a register,   but due to being an addressable named return value, would up   on the stack, this variable holds the named return value's   original location.  */static rtx original_result_rtx;/* Sequence of insns which represents base initialization.  */tree base_init_expr;/* C++: Keep these around to reduce calls to `get_identifier'.   Identifiers for `this' in member functions and the auto-delete   parameter for destructors.  */tree this_identifier, in_charge_identifier;tree ctor_identifier, dtor_identifier;/* Used in pointer to member functions, in vtables, and in sigtables.  */tree pfn_identifier, index_identifier, delta_identifier, delta2_identifier;tree pfn_or_delta2_identifier, tag_identifier;tree vt_off_identifier;struct named_label_list{  struct binding_level *binding_level;  tree names_in_scope;  tree label_decl;  char *filename_o_goto;  int lineno_o_goto;  struct named_label_list *next;};/* A list (chain of TREE_LIST nodes) of named label uses.   The TREE_PURPOSE field is the list of variables defined   in the label's scope defined at the point of use.   The TREE_VALUE field is the LABEL_DECL used.   The TREE_TYPE field holds `current_binding_level' at the   point of the label's use.

⌨️ 快捷键说明

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