📄 decl2.c
字号:
/* Process declarations and variables for C compiler. Copyright (C) 1988, 1992, 1993, 1994, 1995 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 <stdio.h>#include "tree.h"#include "rtl.h"#include "flags.h"#include "cp-tree.h"#include "decl.h"#include "lex.h"#include "output.h"#include "defaults.h"extern tree get_file_function_name ();extern tree cleanups_this_call;static void grok_function_init ();/* 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. */tree pending_statics;/* A list of functions which were declared inline, but which we may need to emit outline anyway. */static tree saved_inlines;/* 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;/* Functions called along with real static constructors and destructors. */tree static_ctors, static_dtors;/* 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. */int flag_traditional;/* Nonzero means to treat bitfields as unsigned unless they say `signed'. */int flag_signed_bitfields = 1;/* Nonzero means handle `#ident' directives. 0 means ignore them. */int flag_no_ident;/* 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 warn about implicit declarations. */int warn_implicit = 1;/* Nonzero means warn when all ctors or dtors are private, and the class has no friends. */int warn_ctor_dtor_privacy = 1;/* True if we want to implement vtbvales using "thunks". The default is off now, but will be on later. */int flag_vtable_thunks;/* True if we want to deal with repository information. */int flag_use_repository;/* Nonzero means give string constants the type `const char *' to get extra warnings from them. These warnings will be too numerous to be useful, except in thoroughly ANSIfied programs. */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 that dbx info for template class methods isn't fully supported yet. */int warn_template_debugging;/* Warn about traditional constructs whose meanings changed in ANSI C. */int warn_traditional;/* Nonzero means warn about sizeof(function) or addition/subtraction of function pointers. */int warn_pointer_arith;/* Nonzero means warn for non-prototype function decls or non-prototyped defs without previous prototype. */int warn_strict_prototypes;/* 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 *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;/* Nonzero means `$' can be in an identifier. See cccp.c for reasons why this breaks some obscure ANSI C programs. */#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. */ /* Nonzero for -fall-virtual: make every member function (except constructors) lay down in the virtual function table. Calls can then either go through the virtual function table or not, depending. */int flag_all_virtual;/* 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;/* Nonzero means memoize our member lookups. */int flag_memoize_lookups; int flag_save_memoized_contexts;/* 3 means write out only virtuals function tables `defined' in this implementation file. 2 means write out only specific virtual function tables and give them (C) public access. 1 means write out virtual function tables and give them (C) public access. 0 means write out virtual function tables and give them (C) static access (default). -1 means declare virtual function tables extern. */int write_virtuals;/* Nonzero means we should attempt to elide constructors when possible. */int flag_elide_constructors;/* Nonzero means recognize and handle exception handling constructs. Use ansi syntax and semantics. WORK IN PROGRESS! */int flag_handle_exceptions;/* 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 enums and ints freely convert. 1 means with complete freedom. 0 means enums can convert to ints, but not vice-versa. */int flag_int_enum_equivalence;/* Controls whether compiler is operating under LUCID's Cadillac system. 1 means yes, 0 means no. */int flag_cadillac;/* Controls whether compiler generates code to build objects that can be collected when they become garbage. */int flag_gc;/* Controls whether compiler generates 'type descriptor' that give run-time type information. */int flag_rtti;/* Nonzero if we wish to output cross-referencing information for the GNU class browser. */extern int flag_gnu_xref;/* Nonzero if compiler can make `reasonable' assumptions about references and objects. For example, the compiler must be conservative about the following and not assume that `a' is nonnull: obj &a = g (); a.f (2); In general, it is `reasonable' to assume that for many programs, and better code can be generated in that case. */int flag_assume_nonnull_objects = 1;/* 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;/* Nonzero if we want to check the return value of new and avoid calling constructors if it is a null pointer. */int flag_check_new;/* Nonzero if we want the new ANSI rules for pushing a new scope for `for' initialization variables. 0: Old rules, set by -fno-for-scope. 2: New ANSI rules, set by -ffor-scope. 1: Try to implement new ANSI rules, but with backup compatibility (and warnings). This is the default, for now. */int flag_new_for_scope = 1;/* Table of language-dependent -f options. STRING is the option name. VARIABLE is the address of the variable. ON_VALUE is the value to store in VARIABLE if `-fSTRING' is seen as an option. (If `-fno-STRING' is seen as an option, the opposite value is stored.) */static struct { char *string; int *variable; int on_value;} lang_f_options[] ={ {"signed-char", &flag_signed_char, 1}, {"unsigned-char", &flag_signed_char, 0}, {"signed-bitfields", &flag_signed_bitfields, 1}, {"unsigned-bitfields", &flag_signed_bitfields, 0}, {"short-enums", &flag_short_enums, 1}, {"short-double", &flag_short_double, 1}, {"cond-mismatch", &flag_cond_mismatch, 1}, {"asm", &flag_no_asm, 0}, {"builtin", &flag_no_builtin, 0}, {"ident", &flag_no_ident, 0}, {"labels-ok", &flag_labels_ok, 1}, {"stats", &flag_detailed_statistics, 1}, {"this-is-variable", &flag_this_is_variable, 1}, {"strict-prototype", &flag_strict_prototype, 1}, {"all-virtual", &flag_all_virtual, 1}, {"memoize-lookups", &flag_memoize_lookups, 1}, {"elide-constructors", &flag_elide_constructors, 1}, {"handle-exceptions", &flag_handle_exceptions, 1}, {"handle-signatures", &flag_handle_signatures, 1}, {"default-inline", &flag_default_inline, 1}, {"dollars-in-identifiers", &dollars_in_ident, 1}, {"enum-int-equiv", &flag_int_enum_equivalence, 1}, {"gc", &flag_gc, 1}, {"rtti", &flag_rtti, 1}, {"xref", &flag_gnu_xref, 1}, {"nonnull-objects", &flag_assume_nonnull_objects, 1}, {"implement-inlines", &flag_implement_inlines, 1}, {"external-templates", &flag_external_templates, 1}, {"implicit-templates", &flag_implicit_templates, 1}, {"huge-objects", &flag_huge_objects, 1}, {"conserve-space", &flag_conserve_space, 1}, {"vtable-thunks", &flag_vtable_thunks, 1}, {"short-temps", &flag_short_temps, 1}, {"access-control", &flag_access_control, 1}, {"nonansi-builtins", &flag_no_nonansi_builtin, 0}, {"gnu-keywords", &flag_no_gnu_keywords, 0}, {"operator-names", &flag_operator_names, 1}, {"check-new", &flag_check_new, 1}, {"repo", &flag_use_repository, 1}, {"for-scope", &flag_new_for_scope, 2}};/* Decode the string P as a language-specific option. Return 1 if it is recognized (and handle it); return 0 if not recognized. */int lang_decode_option (p) char *p;{ if (!strcmp (p, "-ftraditional") || !strcmp (p, "-traditional")) flag_traditional = 1, dollars_in_ident = 1, flag_writable_strings = 1, flag_this_is_variable = 1, flag_new_for_scope = 0; /* The +e options are for cfront compatibility. They come in as `-+eN', to kludge around gcc.c's argument handling. */ else if (p[0] == '-' && p[1] == '+' && p[2] == 'e') { int old_write_virtuals = write_virtuals; if (p[3] == '1') write_virtuals = 1; else if (p[3] == '0') write_virtuals = -1; else if (p[3] == '2')
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -