📄 c-decl.c
字号:
tree static_ctors, static_dtors;/* Forward declarations. */static tree grokparms (), grokdeclarator ();tree pushdecl ();tree builtin_function ();void shadow_tag_warned ();static tree lookup_tag ();static tree lookup_tag_reverse ();tree lookup_name_current_level ();static char *redeclaration_error_message ();static void layout_array_type ();/* C-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 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 allow single precision math even if we're generally being traditional. */int flag_allow_single_precision = 0;/* Nonzero means to treat bitfields as signed unless they say `unsigned'. */int flag_signed_bitfields = 1;int explicit_flag_signed_bitfields = 0;/* Nonzero means handle `#ident' directives. 0 means ignore them. */int flag_no_ident = 0;/* Nonzero means warn about implicit declarations. */int warn_implicit;/* 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 when casting a function call to a type that does not match the return type (e.g. (float)sqrt() or (anything*)malloc() when there is no previous declaration of sqrt or malloc. */int warn_bad_function_cast;/* 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 global function def without separate previous prototype decl. */int warn_missing_prototypes;/* Nonzero means warn for any global function def without separate previous decl. */int warn_missing_declarations;/* Nonzero means warn about multiple (redundant) decls for the same single variable or function. */int warn_redundant_decls = 0;/* Nonzero means warn about extern declarations of objects not at file-scope level and about *all* declarations of functions (whether extern or static) not at file-scope level. Note that we exclude implicit function declarations. To get warnings about those, use -Wimplicit. */int warn_nested_externs = 0;/* Warn about *printf or *scanf format/argument anomalies. */int warn_format;/* Warn about a subscript that has type char. */int warn_char_subscripts = 0;/* Warn if a type conversion is done that might have confusing results. */int warn_conversion;/* Warn if adding () is suggested. */int warn_parentheses;/* Warn if initializer is not completely bracketed. */int warn_missing_braces;/* 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 > 1;/* Decode the string P as a language-specific option for C. Return 1 if it is recognized (and handle it); return 0 if not recognized. */ intc_decode_option (p) char *p;{ if (!strcmp (p, "-ftraditional") || !strcmp (p, "-traditional")) { flag_traditional = 1; flag_writable_strings = 1;#if DOLLARS_IN_IDENTIFIERS > 0 dollars_in_ident = 1;#endif } else if (!strcmp (p, "-fallow-single-precision")) flag_allow_single_precision = 1; else if (!strcmp (p, "-fnotraditional") || !strcmp (p, "-fno-traditional")) { flag_traditional = 0; flag_writable_strings = 0; dollars_in_ident = DOLLARS_IN_IDENTIFIERS > 1; } else if (!strcmp (p, "-fdollars-in-identifiers")) {#if DOLLARS_IN_IDENTIFIERS > 0 dollars_in_ident = 1;#endif } else if (!strcmp (p, "-fno-dollars-in-identifiers")) dollars_in_ident = 0; else if (!strcmp (p, "-fsigned-char")) flag_signed_char = 1; else if (!strcmp (p, "-funsigned-char")) flag_signed_char = 0; else if (!strcmp (p, "-fno-signed-char")) flag_signed_char = 0; else if (!strcmp (p, "-fno-unsigned-char")) flag_signed_char = 1; else if (!strcmp (p, "-fsigned-bitfields") || !strcmp (p, "-fno-unsigned-bitfields")) { flag_signed_bitfields = 1; explicit_flag_signed_bitfields = 1; } else if (!strcmp (p, "-funsigned-bitfields") || !strcmp (p, "-fno-signed-bitfields")) { flag_signed_bitfields = 0; explicit_flag_signed_bitfields = 1; } else if (!strcmp (p, "-fshort-enums")) flag_short_enums = 1; else if (!strcmp (p, "-fno-short-enums")) flag_short_enums = 0; else if (!strcmp (p, "-fcond-mismatch")) flag_cond_mismatch = 1; else if (!strcmp (p, "-fno-cond-mismatch")) flag_cond_mismatch = 0; else if (!strcmp (p, "-fshort-double")) flag_short_double = 1; else if (!strcmp (p, "-fno-short-double")) flag_short_double = 0; else if (!strcmp (p, "-fasm")) flag_no_asm = 0; else if (!strcmp (p, "-fno-asm")) flag_no_asm = 1; else if (!strcmp (p, "-fbuiltin")) flag_no_builtin = 0; else if (!strcmp (p, "-fno-builtin")) flag_no_builtin = 1; else if (!strcmp (p, "-fno-ident")) flag_no_ident = 1; else if (!strcmp (p, "-fident")) flag_no_ident = 0; else if (!strcmp (p, "-ansi")) flag_no_asm = 1, flag_no_nonansi_builtin = 1, dollars_in_ident = 0; else if (!strcmp (p, "-Wimplicit")) warn_implicit = 1; else if (!strcmp (p, "-Wno-implicit")) warn_implicit = 0; else if (!strcmp (p, "-Wwrite-strings")) warn_write_strings = 1; else if (!strcmp (p, "-Wno-write-strings")) warn_write_strings = 0; else if (!strcmp (p, "-Wcast-qual")) warn_cast_qual = 1; else if (!strcmp (p, "-Wno-cast-qual")) warn_cast_qual = 0; else if (!strcmp (p, "-Wbad-function-cast")) warn_bad_function_cast = 1; else if (!strcmp (p, "-Wno-bad-function-cast")) warn_bad_function_cast = 0; else if (!strcmp (p, "-Wpointer-arith")) warn_pointer_arith = 1; else if (!strcmp (p, "-Wno-pointer-arith")) warn_pointer_arith = 0; else if (!strcmp (p, "-Wstrict-prototypes")) warn_strict_prototypes = 1; else if (!strcmp (p, "-Wno-strict-prototypes")) warn_strict_prototypes = 0; else if (!strcmp (p, "-Wmissing-prototypes")) warn_missing_prototypes = 1; else if (!strcmp (p, "-Wno-missing-prototypes")) warn_missing_prototypes = 0; else if (!strcmp (p, "-Wmissing-declarations")) warn_missing_declarations = 1; else if (!strcmp (p, "-Wno-missing-declarations")) warn_missing_declarations = 0; else if (!strcmp (p, "-Wredundant-decls")) warn_redundant_decls = 1; else if (!strcmp (p, "-Wno-redundant-decls")) warn_redundant_decls = 0; else if (!strcmp (p, "-Wnested-externs")) warn_nested_externs = 1; else if (!strcmp (p, "-Wno-nested-externs")) warn_nested_externs = 0; else if (!strcmp (p, "-Wtraditional")) warn_traditional = 1; else if (!strcmp (p, "-Wno-traditional")) warn_traditional = 0; else if (!strcmp (p, "-Wformat")) warn_format = 1; else if (!strcmp (p, "-Wno-format")) warn_format = 0; else if (!strcmp (p, "-Wchar-subscripts")) warn_char_subscripts = 1; else if (!strcmp (p, "-Wno-char-subscripts")) warn_char_subscripts = 0; else if (!strcmp (p, "-Wconversion")) warn_conversion = 1; else if (!strcmp (p, "-Wno-conversion")) warn_conversion = 0; else if (!strcmp (p, "-Wparentheses")) warn_parentheses = 1; else if (!strcmp (p, "-Wno-parentheses")) warn_parentheses = 0; else if (!strcmp (p, "-Wreturn-type")) warn_return_type = 1; else if (!strcmp (p, "-Wno-return-type")) warn_return_type = 0; else if (!strcmp (p, "-Wcomment")) ; /* cpp handles this one. */ else if (!strcmp (p, "-Wno-comment")) ; /* cpp handles this one. */ else if (!strcmp (p, "-Wcomments")) ; /* cpp handles this one. */ else if (!strcmp (p, "-Wno-comments")) ; /* cpp handles this one. */ else if (!strcmp (p, "-Wtrigraphs")) ; /* cpp handles this one. */ else if (!strcmp (p, "-Wno-trigraphs")) ; /* cpp handles this one. */ else if (!strcmp (p, "-Wimport")) ; /* cpp handles this one. */ else if (!strcmp (p, "-Wno-import")) ; /* cpp handles this one. */ else if (!strcmp (p, "-Wmissing-braces")) warn_missing_braces = 1; else if (!strcmp (p, "-Wno-missing-braces")) warn_missing_braces = 0; else if (!strcmp (p, "-Wall")) { /* We save the value of warn_uninitialized, since if they put -Wuninitialized on the command line, we need to generate a warning about not using it without also specifying -O. */ if (warn_uninitialized != 1) warn_uninitialized = 2; warn_implicit = 1; warn_return_type = 1; warn_unused = 1; warn_switch = 1; warn_format = 1; warn_char_subscripts = 1; warn_parentheses = 1; warn_missing_braces = 1; } else return 0; return 1;}/* Hooks for print_node. */voidprint_lang_decl (file, node, indent) FILE *file; tree node; int indent;{}voidprint_lang_type (file, node, indent) FILE *file; tree node; int indent;{}voidprint_lang_identifier (file, node, indent) FILE *file; tree node; int indent;{ print_node (file, "global", IDENTIFIER_GLOBAL_VALUE (node), indent + 4); print_node (file, "local", IDENTIFIER_LOCAL_VALUE (node), indent + 4); print_node (file, "label", IDENTIFIER_LABEL_VALUE (node), indent + 4); print_node (file, "implicit", IDENTIFIER_IMPLICIT_DECL (node), indent + 4); print_node (file, "error locus", IDENTIFIER_ERROR_LOCUS (node), indent + 4); print_node (file, "limbo value", IDENTIFIER_LIMBO_VALUE (node), indent + 4);}/* Hook called at end of compilation to assume 1 elt for a top-level array decl that wasn't complete before. */ voidfinish_incomplete_decl (decl) tree decl;{ if (TREE_CODE (decl) == VAR_DECL && TREE_TYPE (decl) != error_mark_node) { tree type = TREE_TYPE (decl); if (TREE_CODE (type) == ARRAY_TYPE && TYPE_DOMAIN (type) == 0 && TREE_CODE (decl) != TYPE_DECL) { complete_array_type (type, NULL_TREE, 1); layout_decl (decl, 0); } }}/* Create a new `struct binding_level'. */staticstruct binding_level *make_binding_level (){ /* NOSTRICT */ return (struct binding_level *) xmalloc (sizeof (struct binding_level));}/* Nonzero if we are currently in the global binding level. */intglobal_bindings_p (){ return current_binding_level == global_binding_level;}voidkeep_next_level (){ keep_next_level_flag = 1;}/* Nonzero if the current level needs to have a BLOCK made. */intkept_level_p ()
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -