📄 decl2.c
字号:
{"elide-constructors", &flag_elide_constructors, 1}, {"handle-exceptions", &flag_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}, {"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}, {"ansi-overloading", &flag_ansi_overloading, 1}, {"huge-objects", &flag_huge_objects, 1}, {"conserve-space", &flag_conserve_space, 1}, {"vtable-thunks", &flag_vtable_thunks, 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}, {"weak", &flag_weak, 1}};/* 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_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') write_virtuals = 2; else error ("invalid +e option"); if (old_write_virtuals != 0 && write_virtuals != old_write_virtuals) error ("conflicting +e options given"); } else if (p[0] == '-' && p[1] == 'f') { /* Some kind of -f option. P's value is the option sans `-f'. Search for it in the table of options. */ int found = 0, j; p += 2; /* Try special -f options. */ if (!strcmp (p, "handle-exceptions") || !strcmp (p, "no-handle-exceptions")) warning ("-fhandle-exceptions has been renamed to -fexceptions (and is now on by default)"); if (!strcmp (p, "save-memoized")) { flag_memoize_lookups = 1; flag_save_memoized_contexts = 1; found = 1; } else if (!strcmp (p, "no-save-memoized")) { flag_memoize_lookups = 0; flag_save_memoized_contexts = 0; found = 1; } else if (! strcmp (p, "alt-external-templates")) { flag_external_templates = 1; flag_alt_external_templates = 1; found = 1; } else if (! strcmp (p, "no-alt-external-templates")) { flag_alt_external_templates = 0; found = 1; } else if (!strcmp (p, "repo")) { flag_use_repository = 1; flag_implicit_templates = 0; found = 1; } else if (!strcmp (p, "guiding-decls")) { flag_guiding_decls = 1; name_mangling_version = 0; found = 1; } else if (!strcmp (p, "no-guiding-decls")) { flag_guiding_decls = 0; found = 1; } else if (!strncmp (p, "template-depth-", 15)) { char *endp = p + 15; while (*endp) { if (*endp >= '0' && *endp <= '9') endp++; else { error ("Invalid option `%s'", p - 2); goto template_depth_lose; } } max_tinst_depth = atoi (p + 15); template_depth_lose: ; } else if (!strncmp (p, "name-mangling-version-", 22)) { char *endp = p + 22; while (*endp) { if (*endp >= '0' && *endp <= '9') endp++; else { error ("Invalid option `%s'", p - 2); goto mangling_version_lose; } } name_mangling_version = atoi (p + 22); mangling_version_lose: ; } else for (j = 0; !found && j < sizeof (lang_f_options) / sizeof (lang_f_options[0]); j++) { if (!strcmp (p, lang_f_options[j].string)) { *lang_f_options[j].variable = lang_f_options[j].on_value; /* A goto here would be cleaner, but breaks the vax pcc. */ found = 1; } if (p[0] == 'n' && p[1] == 'o' && p[2] == '-' && ! strcmp (p+3, lang_f_options[j].string)) { *lang_f_options[j].variable = ! lang_f_options[j].on_value; found = 1; } } return found; } else if (p[0] == '-' && p[1] == 'W') { int setting = 1; /* The -W options control the warning behavior of the compiler. */ p += 2; if (p[0] == 'n' && p[1] == 'o' && p[2] == '-') setting = 0, p += 3; if (!strcmp (p, "implicit")) warn_implicit = setting; else if (!strcmp (p, "return-type")) warn_return_type = setting; else if (!strcmp (p, "ctor-dtor-privacy")) warn_ctor_dtor_privacy = setting; else if (!strcmp (p, "write-strings")) warn_write_strings = setting; else if (!strcmp (p, "cast-qual")) warn_cast_qual = setting; else if (!strcmp (p, "char-subscripts")) warn_char_subscripts = setting; else if (!strcmp (p, "pointer-arith")) warn_pointer_arith = setting; else if (!strcmp (p, "missing-prototypes")) warn_missing_prototypes = setting; else if (!strcmp (p, "redundant-decls")) warn_redundant_decls = setting; else if (!strcmp (p, "missing-braces")) warn_missing_braces = setting; else if (!strcmp (p, "sign-compare")) warn_sign_compare = setting; else if (!strcmp (p, "format")) warn_format = setting; else if (!strcmp (p, "conversion")) warn_conversion = setting; else if (!strcmp (p, "parentheses")) warn_parentheses = setting; else if (!strcmp (p, "non-virtual-dtor")) warn_nonvdtor = setting; else if (!strcmp (p, "extern-inline")) warn_extern_inline = setting; else if (!strcmp (p, "reorder")) warn_reorder = setting; else if (!strcmp (p, "synth")) warn_synth = setting; else if (!strcmp (p, "pmf-conversions")) warn_pmf2ptr = setting; else if (!strcmp (p, "effc++")) warn_ecpp = setting; else if (!strcmp (p, "sign-promo")) warn_sign_promo = setting; else if (!strcmp (p, "old-style-cast")) warn_old_style_cast = setting; else if (!strcmp (p, "comment")) ; /* cpp handles this one. */ else if (!strcmp (p, "comments")) ; /* cpp handles this one. */ else if (!strcmp (p, "trigraphs")) ; /* cpp handles this one. */ else if (!strcmp (p, "import")) ; /* cpp handles this one. */ else if (!strcmp (p, "all")) { warn_return_type = setting; warn_unused = setting; warn_implicit = setting; warn_ctor_dtor_privacy = setting; warn_switch = setting; warn_format = setting; warn_parentheses = setting; warn_missing_braces = setting; warn_sign_compare = setting; warn_extern_inline = setting; warn_nonvdtor = setting; /* 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 = (setting ? 2 : 0); warn_template_debugging = setting; warn_reorder = setting; warn_sign_promo = setting; } else if (!strcmp (p, "overloaded-virtual")) warn_overloaded_virtual = setting; else return 0; } else if (!strcmp (p, "-ansi")) flag_no_nonansi_builtin = 1, flag_ansi = 1, flag_no_gnu_keywords = 1, flag_operator_names = 1;#ifdef SPEW_DEBUG /* Undocumented, only ever used when you're invoking cc1plus by hand, since it's probably safe to assume no sane person would ever want to use this under normal circumstances. */ else if (!strcmp (p, "-spew-debug")) spew_debug = 1;#endif else return 0; return 1;}/* Incorporate `const' and `volatile' qualifiers for member functions. FUNCTION is a TYPE_DECL or a FUNCTION_DECL. QUALS is a list of qualifiers. */treegrok_method_quals (ctype, function, quals) tree ctype, function, quals;{ tree fntype = TREE_TYPE (function); tree raises = TYPE_RAISES_EXCEPTIONS (fntype); do { extern tree ridpointers[]; if (TREE_VALUE (quals) == ridpointers[(int)RID_CONST]) { if (TYPE_READONLY (ctype)) error ("duplicate `%s' %s", IDENTIFIER_POINTER (TREE_VALUE (quals)), (TREE_CODE (function) == FUNCTION_DECL ? "for member function" : "in type declaration")); ctype = build_type_variant (ctype, 1, TYPE_VOLATILE (ctype)); build_pointer_type (ctype); } else if (TREE_VALUE (quals) == ridpointers[(int)RID_VOLATILE]) { if (TYPE_VOLATILE (ctype)) error ("duplicate `%s' %s", IDENTIFIER_POINTER (TREE_VALUE (quals)), (TREE_CODE (function) == FUNCTION_DECL ? "for member function" : "in type declaration")); ctype = build_type_variant (ctype, TYPE_READONLY (ctype), 1); build_pointer_type (ctype); } else my_friendly_abort (20); quals = TREE_CHAIN (quals); } while (quals); fntype = build_cplus_method_type (ctype, TREE_TYPE (fntype), (TREE_CODE (fntype) == METHOD_TYPE ? TREE_CHAIN (TYPE_ARG_TYPES (fntype)) : TYPE_ARG_TYPES (fntype))); if (raises) fntype = build_exception_variant (fntype, raises); TREE_TYPE (function) = fntype; return ctype;}#if 0 /* Not used. *//* This routine replaces cryptic DECL_NAMEs with readable DECL_NAMEs. It leaves DECL_ASSEMBLER_NAMEs with the correct value. *//* This does not yet work with user defined conversion operators It should. */static voidsubstitute_nice_name (decl) tree decl;{ if (DECL_NAME (decl) && TREE_CODE (DECL_NAME (decl)) == IDENTIFIER_NODE) { char *n = decl_as_string (DECL_NAME (decl), 1); if (n[strlen (n) - 1] == ' ') n[strlen (n) - 1] = 0; DECL_NAME (decl) = get_identifier (n); }}#endif/* Warn when -fexternal-templates is used and #pragma interface/implementation is not used all the times it should be, inform the user. */voidwarn_if_unknown_interface (decl) tree decl;{ static int already_warned = 0; if (already_warned++) return; if (flag_alt_external_templates) { struct tinst_level *til = tinst_for_decl (); int sl = lineno; char *sf = input_filename; if (til) { lineno = til->line; input_filename = til->file; } cp_warning ("template `%#D' instantiated in file without #pragma interface", decl); lineno = sl; input_filename = sf; } else cp_warning_at ("template `%#D' defined in file without #pragma interface", decl);}/* A subroutine of the parser, to handle a component list. */treegrok_x_components (specs, components) tree specs, components;{ register tree t, x, tcode; /* We just got some friends. They have been recorded elsewhere. */ if (components == void_type_node) return NULL_TREE; if (components == NULL_TREE) { t = groktypename (build_decl_list (specs, NULL_TREE)); if (t == NULL_TREE) { error ("error in component specification"); return NULL_TREE; } switch (TREE_CODE (t)) { case VAR_DECL: /* Static anonymous unions come out as VAR_DECLs. */ if (TREE_CODE (TREE_TYPE (t)) == UNION_TYPE && ANON_AGGRNAME_P (TYPE_IDENTIFIER (TREE_TYPE (t)))) return t; /* We return SPECS here, because in the parser it was ending up with not doing anything to $$, which is what SPECS represents. */ return specs; break; case RECORD_TYPE: /* This code may be needed for UNION_TYPEs as well. */ tcode = record_type_node; if (CLASSTYPE_DECLARED_CLASS (t)) tcode = class_type_node; else if (IS_SIGNATURE (t)) tcode = signature_type_node; t = xref_tag (tcode, TYPE_IDENTIFIER (t), NULL_TREE, 0); if (TYPE_CONTEXT (t)) CLASSTYPE_NO_GLOBALIZE (t) = 1; return NULL_TREE; break; case UNION_TYPE: case ENUMERAL_TYPE: if (TREE_CODE (t) == UNION_TYPE) tcode = union_type_node; else tcode = enum_type_node; t = xref_tag (tcode, TYPE_IDENTIFIER (t), NULL_TREE, 0); if (TREE_CODE (t) == UNION_TYPE && TYPE_CONTEXT (t)) CLASSTYPE_NO_GLOBALIZE (t) = 1; if (TREE_CODE (t) == UNION_TYPE && ANON_AGGRNAME_P (TYPE_IDENTIFIER (t))) { /* See also shadow_tag. */ struct pending_inline **p; tree *q; x = build_lang_field_decl (FIELD_DECL, NULL_TREE, t); /* Wipe out memory of synthesized methods */ TYPE_HAS_CONSTRUCTOR (t) = 0; TYPE_HAS_DEFAULT_CONSTRUCTOR (t) = 0; TYPE_HAS_INIT_REF (t) = 0;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -