📄 decl2.c
字号:
/* Process declarations and variables for C compiler. Copyright (C) 1988, 92-98, 1999 Free Software Foundation, Inc. Hacked 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 "output.h"#include "except.h"#include "expr.h"#include "defaults.h"#include "toplev.h"#include "dwarf2out.h"#include "dwarfout.h"#include "splay-tree.h"#include "varray.h"#if USE_CPPLIB#include "cpplib.h"extern cpp_reader parse_in;#endif/* This structure contains information about the initializations and/or destructions required for a particular priority level. */typedef struct priority_info_s { /* A label indicating where we should generate the next initialization with this priority. */ rtx initialization_sequence; /* A label indicating where we should generate the next destruction with this priority. */ rtx destruction_sequence; /* Non-zero if there have been any initializations at this priority throughout the translation unit. */ int initializations_p; /* Non-zero if there have been any destructions at this priority throughout the translation unit. */ int destructions_p;} *priority_info;static tree get_sentry PROTO((tree));static void mark_vtable_entries PROTO((tree));static void grok_function_init PROTO((tree, tree));static int finish_vtable_vardecl PROTO((tree *, void *));static int prune_vtable_vardecl PROTO((tree *, void *));static int finish_sigtable_vardecl PROTO((tree *, void *));static int is_namespace_ancestor PROTO((tree, tree));static void add_using_namespace PROTO((tree, tree, int));static tree ambiguous_decl PROTO((tree, tree, tree,int));static tree build_anon_union_vars PROTO((tree, tree*, int, int));static int acceptable_java_type PROTO((tree));static void output_vtable_inherit PROTO((tree));static void start_objects PROTO((int, int));static void finish_objects PROTO((int, int));static tree merge_functions PROTO((tree, tree));static tree decl_namespace PROTO((tree));static tree validate_nonmember_using_decl PROTO((tree, tree *, tree *));static void do_nonmember_using_decl PROTO((tree, tree, tree, tree, tree *, tree *));static void start_static_storage_duration_function PROTO((void));static int generate_inits_for_priority PROTO((splay_tree_node, void *));static void finish_static_storage_duration_function PROTO((void));static priority_info get_priority_info PROTO((int));static void do_static_initialization PROTO((tree, tree, tree, int));static void do_static_destruction PROTO((tree, tree, int));static void do_static_initialization_and_destruction PROTO((tree, tree));static void generate_ctor_or_dtor_function PROTO((int, int));static int generate_ctor_and_dtor_functions_for_priority PROTO((splay_tree_node, void *));extern int current_class_depth;/* A list of virtual function tables we must make sure to write out. */tree pending_vtables;/* A list of static class variables. This is needed, because a static class variable can be declared inside the class without an initializer, and then initialized, staticly, outside the class. */static varray_type pending_statics;static size_t pending_statics_used;/* A list of functions which were declared inline, but which we may need to emit outline anyway. */static varray_type saved_inlines;static size_t saved_inlines_used;/* Used to help generate temporary names which are unique within a function. Reset to 0 by start_function. */int temp_name_counter;/* Same, but not reset. Local temp variables and global temp variables can have the same name. */static int global_temp_name_counter;/* Flag used when debugging spew.c */extern int spew_debug;/* Nonzero if we're done parsing and into end-of-file activities. */int at_eof;/* Functions called along with real static constructors and destructors. */tree static_ctors, static_dtors;/* The current open namespace, and ::. */tree current_namespace;tree global_namespace;/* The stack for namespaces of current declarations. */static tree decl_namespace_list;/* C (and C++) language-specific option variables. *//* Nonzero means allow type mismatches in conditional expressions; just make their values `void'. */int flag_cond_mismatch;/* Nonzero means give `double' the same size as `float'. */int flag_short_double;/* Nonzero means don't recognize the keyword `asm'. */int flag_no_asm;/* Nonzero means don't recognize any extension keywords. */int flag_no_gnu_keywords;/* Nonzero means don't recognize the non-ANSI builtin functions. */int flag_no_builtin;/* Nonzero means don't recognize the non-ANSI builtin functions. -ansi sets this. */int flag_no_nonansi_builtin;/* Nonzero means do some things the same way PCC does. Only provided so the compiler will link. */int flag_traditional;/* Nonzero means to treat bitfields as unsigned unless they say `signed'. */int flag_signed_bitfields = 1;/* Nonzero means enable obscure ANSI features and disable GNU extensions that might cause ANSI-compliant code to be miscompiled. */int flag_ansi;/* Nonzero means do emit exported implementations of functions even if they can be inlined. */int flag_implement_inlines = 1;/* Nonzero means do emit exported implementations of templates, instead of multiple static copies in each file that needs a definition. */int flag_external_templates;/* Nonzero means that the decision to emit or not emit the implementation of a template depends on where the template is instantiated, rather than where it is defined. */int flag_alt_external_templates;/* Nonzero means that implicit instantiations will be emitted if needed. */int flag_implicit_templates = 1;/* Nonzero means that implicit instantiations of inline templates will be emitted if needed, even if instantiations of non-inline templates aren't. */int flag_implicit_inline_templates = 1;/* Nonzero means warn about implicit declarations. */int warn_implicit = 1;/* Nonzero means warn about usage of long long when `-pedantic'. */int warn_long_long = 1;/* Nonzero means warn when all ctors or dtors are private, and the class has no friends. */int warn_ctor_dtor_privacy = 1;/* 1 or 2 if we want to implement vtables using "thunks". The default is off. Version 1 indicates "old" implementation; Version 2 passes the __vlist argument in pvbase cases. */#ifndef DEFAULT_VTABLE_THUNKS#define DEFAULT_VTABLE_THUNKS 0#endifint flag_vtable_thunks = DEFAULT_VTABLE_THUNKS;#if DEFAULT_VTABLE_THUNKS == 2int flag_vtable_thunks_compat = 1;#elseint flag_vtable_thunks_compat = 0;#endif/* True if we want to deal with repository information. */int flag_use_repository;/* Nonzero if we want to issue diagnostics that the standard says are not required. */int flag_optional_diags = 1;/* Nonzero means give string constants the type `const char *', as mandated by the standard. */int flag_const_strings = 1;/* Nonzero means warn about deprecated conversion from string constant to `char *'. */int warn_write_strings;/* Nonzero means warn about pointer casts that can drop a type qualifier from the pointer target type. */int warn_cast_qual;/* Nonzero means warn about sizeof(function) or addition/subtraction of function pointers. */int warn_pointer_arith = 1;/* Nonzero means warn for any function def without prototype decl. */int warn_missing_prototypes;/* Nonzero means warn about multiple (redundant) decls for the same single variable or function. */int warn_redundant_decls;/* Warn if initializer is not completely bracketed. */int warn_missing_braces;/* Warn about comparison of signed and unsigned values. */int warn_sign_compare;/* Warn about *printf or *scanf format/argument anomalies. */int warn_format;/* Warn about a subscript that has type char. */int warn_char_subscripts;/* Warn if a type conversion is done that might have confusing results. */int warn_conversion;/* Warn if adding () is suggested. */int warn_parentheses;/* Non-zero means warn in function declared in derived class has the same name as a virtual in the base class, but fails to match the type signature of any virtual function in the base class. */int warn_overloaded_virtual;/* Non-zero means warn when declaring a class that has a non virtual destructor, when it really ought to have a virtual one. */int warn_nonvdtor;/* Non-zero means warn when a function is declared extern and later inline. */int warn_extern_inline;/* Non-zero means warn when the compiler will reorder code. */int warn_reorder;/* Non-zero means warn when synthesis behavior differs from Cfront's. */int warn_synth;/* Non-zero means warn when we convert a pointer to member function into a pointer to (void or function). */int warn_pmf2ptr = 1;/* Nonzero means warn about violation of some Effective C++ style rules. */int warn_ecpp;/* Nonzero means warn where overload resolution chooses a promotion from unsigned to signed over a conversion to an unsigned of the same size. */int warn_sign_promo;/* Nonzero means warn when an old-style cast is used. */int warn_old_style_cast;/* Warn about #pragma directives that are not recognised. */ int warn_unknown_pragmas; /* Tri state variable. */ /* Nonzero means warn about use of multicharacter literals. */int warn_multichar = 1;/* Nonzero means warn when non-templatized friend functions are declared within a template */int warn_nontemplate_friend = 1;/* Nonzero means complain about deprecated features. */int warn_deprecated = 1;/* Nonzero means `$' can be in an identifier. */#ifndef DOLLARS_IN_IDENTIFIERS#define DOLLARS_IN_IDENTIFIERS 1#endifint dollars_in_ident = DOLLARS_IN_IDENTIFIERS;/* Nonzero for -fno-strict-prototype switch: do not consider empty argument prototype to mean function takes no arguments. */int flag_strict_prototype = 2;int strict_prototype = 1;int strict_prototypes_lang_c, strict_prototypes_lang_cplusplus = 1;/* Nonzero means that labels can be used as first-class objects */int flag_labels_ok;/* Non-zero means to collect statistics which might be expensive and to print them when we are done. */int flag_detailed_statistics;/* C++ specific flags. */ /* Zero means that `this' is a *const. This gives nice behavior in the 2.0 world. 1 gives 1.2-compatible behavior. 2 gives Spring behavior. -2 means we're constructing an object and it has fixed type. */int flag_this_is_variable;/* 3 means write out only virtuals function tables `defined' in this implementation file. 0 means write out virtual function tables and give them (C) static access (default). */int write_virtuals;/* Nonzero means we should attempt to elide constructors when possible. */int flag_elide_constructors = 1;/* Nonzero means recognize and handle signature language constructs. */int flag_handle_signatures;/* Nonzero means that member functions defined in class scope are inline by default. */int flag_default_inline = 1;/* Controls whether compiler generates 'type descriptor' that give run-time type information. */int flag_rtti = 1;/* Nonzero if we wish to output cross-referencing information for the GNU class browser. */extern int flag_gnu_xref;/* Nonzero if we want to support huge (> 2^(sizeof(short)*8-1) bytes) objects. */int flag_huge_objects;/* Nonzero if we want to conserve space in the .o files. We do this by putting uninitialized data and runtime initialized data into .common instead of .data at the expense of not flagging multiple definitions. */int flag_conserve_space;/* Nonzero if we want to obey access control semantics. */int flag_access_control = 1;/* Nonzero if we want to understand the operator names, i.e. 'bitand'. */int flag_operator_names;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -