diff options
author | dberlin <dberlin@138bc75d-0d04-0410-961f-82ee72b054a4> | 2005-07-08 23:37:11 +0000 |
---|---|---|
committer | dberlin <dberlin@138bc75d-0d04-0410-961f-82ee72b054a4> | 2005-07-08 23:37:11 +0000 |
commit | 5ded8c6f262065518f04c441d1ea847fa38c5b38 (patch) | |
tree | e8e5667e9ce5aa5fc7514d5caa37a74c88e3f391 | |
parent | 6c3c4d74d98659fda5994e5b843fa6b6842ce8aa (diff) | |
download | gcc-5ded8c6f262065518f04c441d1ea847fa38c5b38.tar.gz |
2005-07-08 Daniel Berlin <dberlin@dberlin.org>
* Makefile.in (TREE_H): Add treestruct.def.
(c-decl.o): Add pointer-set.h
* c-decl.c (diagnose_mismatched_decls): Don't attempt to look at
visibility on regular DECL's.
(merge_decls): Fix the copying of decl nodes of various types for
the new structures. Don't update RTL, section name, weak status,
etc, on DECL's without RTL.
(grokdeclarator): DECL_ARG_TYPE_AS_WRITTEN is gone.
Don't check volatile on non-variable types.
(store_parm_decls_oldstyle): Use pointer_set instead of DECL_WEAK
to check whether we have seen arguments.
* c-objc-common.c (c_tree_printer): Reverse order of tests so that
flag is checked before field (flag is common, field is not).
* dwarf2out.c (decl_ultimate_origin): Only DECL's with
TS_DECL_COMMON could have an origin.
(add_location_or_const_value_attribute): Don't check section name
on non-var/function decls.
(dwarf2out_var_location): Reverse order of tests.
* emit-rtl.c (set_reg_attrs_for_parm): DECL_CHECK is dead, replace
with DECL_WRTL_CHECK.
* expmed.c (make_tree): rtl is now in decl_with_rtl.
* fold-const.c (fold_binary): Don't check weakness on
non-var/function decls.
(tree_expr_nonzero_p): Ditto.
(fold_checksum_tree): Use tree_decl_extra as sizeof
buffer.
* ggc-page.c (extra_order_size_table): Add sizes for
tree_decl_non_common, tree_parm_decl, tree_var_decl, and
tree_field_decl.
* gimplify.c (gimplify_bind_expr): Only set
DECL_SEEN_IN_BIND_EXPR_P on VAR_DECL.
* integrate.c (copy_decl_for_inlining): Don't set RTL on decl's
without RTL.
* langhooks-def.h (LANG_HOOK_INIT_TS): New.
* langhooks.h (init_ts). New langhook.
* passes.c (rest_of_decl_compilation): Reverse order of tests.
* print-tree.c (print_node): Update to only print fields that
exist in the structures the passed decl has.
* toplev.c (wrapup_global_declarations): Don't reset
DECL_DEFER_OUTPUT on DECL's that don't contain it.
* tree-browser.c (browse_tree): DECL_ARG_TYPE_AS_WRITTEN removed.
* tree-inline.c (remap_decl): Ditto.
* tree-outof-ssa.c (create_temp): Reverse order of tests.
* tree-pretty-print.c (print_declaration): Don't print
DECL_REGISTER on things that don't contain it.
* tree-vrp.c (expr_computes_nonzero): Don't check weakness on
non-var/function decls.
* tree.c (tree_contains_struct): New structure.
(init_priority_for_decl): New hashtable.
(tree_int_map): New structure.
(tree_int_map_eq): New function.
(tree_int_map_marked_p): Ditto.
(tree_int_map_hash): Ditto.
(tree_map): Move to tree.h.
(tree_map_eq): Externalize.
(tree_map_hash): Ditto.
(tree_map_marked_p): Ditto.
(init_ttree): Set up tree_contains_struct and call langhook.
(decl_assembler_name): Use DECL_NON_COMMON_CHECK..
(tree_code_size): Update for new structures.
(tree_node_structure): Update for new structures.
(make_node_stat): Don't try to set DECL_IN_SYSTEM_HEADER on decls
without the field.
(copy_node_stat): Copy init priority.
(build_decl_stat): Ditto for visibility.
(ts_enum_names): New.
(tree_contains_struct_check_failed): New function.
(decl_init_priority_lookup): Ditto.
(decl_init_priority_insert): Ditto.
* treestruct.def: New file.
* tree.h (CODE_CONTAINS_STRUCT): New macro.
(CONTAINS_STRUCT_CHECK): Ditto.
(tree_contains_struct_check_failed): New prototype.
(DECL_CHECK): Removed.
(DECL_MINIMAL_CHECK): New.
(DECL_COMMON_CHECK): Ditto.
(DECL_WRTL_CHECK): Ditto.
(DECL_NON_COMMON_CHECK): Ditto.
(DECL_WITH_VIS_CHECK): Ditto.
(VAR_OR_FUNCTION_DECL_P): Ditto
(struct tree_decl_minimal): New structure.
(struct tree_decl_common): Ditto.
(struct tree_decl_with_rtl): Ditto.
(struct tree_decl_with_vis): Ditto.
(struct tree_decl_non_common): Ditto.
(struct tree_field_decl): Ditto.
(struct tree_parm_decl): Ditto.
(struct tree_var_decl): Ditto.
(struct tree_function_decl): Ditto.
(struct tree_const_decl): Ditto.
(struct tree_result_decl): Ditto.
(union tree_node): Add new structures.
* var-tracking.c (track_expr_p): Reverse order of tests.
* doc/c-tree.texi: Add documentation on DECL node internal structure.
2005-07-08 Daniel Berlin <dberlin@dberlin.org>
* utils.c (create_param_decl): DECL_ARG_TYPE_AS_WRITTEN is
removed.
2005-07-08 Daniel Berlin <dberlin@dberlin.org>
* Make-lang.in: Add gt-cp-lang.h.
(cp-lang.o): Ditto.
* class.c (create_vtable_ptr): Stop setting DECL_ASSEMBLER_NAME on
the field.
* config-lang.in: Add cp-lang.c to gtfiles.
* cp-lang.c: Include hashtab.h.
(cp_init_ts): New function.
(LANG_HOOK_INIT_TS): Use macro.
(decl_shadowed_for_var_lookup): New function.
(decl_shadowed_for_var_insert): Ditto.
* cp-tree.h (THUNK_FUNCTION_CHECK): Use decl_common.
(NON_THUNK_FUNCTION_CHECK): Ditto.
(DECL_NAMESPACE_ASSOCIATIONS): Use decl_non_common.
(DECL_INIT_PRIORITY): Ditto.
(DECL_HAS_SHADOWED_FOR_VAR_P): Ditto.
(DECL_SHADOWED_FOR_VAR): Use hashtable.
(SET_DECL_SHADOWED_FOR_VAR): Ditto.
* decl.c (duplicate_decls): Update for new/updated structures.
(poplevel): Use SET_DECL_SHADOWED_FOR_VAR.
* decl2.c (start_static_initialization_or_destruction): Deal with
priority.
* pt.c (tsubst_decl): Check TS_DECL_WRTL before doing
SET_DECL_RTL.
* tree.c (handle_init_priority_attribute): Handle priority.
2005-07-08 Daniel Berlin <dberlin@dberlin.org>
* objc-act.c (objc_push_parm): DECL_ARG_TYPE_AS_WRITTEN is
removed.
* objc-act.h (KEYWORD_ARG_NAME): Use decl_non_common.
(KEYWORD_KEY_NAME): Use decl_minimal.
(METHOD_SEL_NAME): Ditto..
(METHOD_SEL_ARGS): Use decl_non_common.
(METHOD_ADD_ARGS): Ditto.
(METHOD_ADD_ARGS_ELLIPSIS_P): Use decl_common.
(METHOD_DEFINITION): Ditto.
(METHOD_ENCODING): Ditto.
* objc-lang.c: (objc_init_ts): New function.
2005-07-08 Daniel Berlin <dberlin@dberlin.org>
* trans-decl.c (create_function_arglist): DECL_ARG_TYPE_AS_WRITTEN
is removed.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@101799 138bc75d-0d04-0410-961f-82ee72b054a4
44 files changed, 1712 insertions, 762 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index bb0df11dcfc..498406c7722 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,101 @@ +2005-07-08 Daniel Berlin <dberlin@dberlin.org> + + * Makefile.in (TREE_H): Add treestruct.def. + (c-decl.o): Add pointer-set.h + * c-decl.c (diagnose_mismatched_decls): Don't attempt to look at + visibility on regular DECL's. + (merge_decls): Fix the copying of decl nodes of various types for + the new structures. Don't update RTL, section name, weak status, + etc, on DECL's without RTL. + (grokdeclarator): DECL_ARG_TYPE_AS_WRITTEN is gone. + Don't check volatile on non-variable types. + (store_parm_decls_oldstyle): Use pointer_set instead of DECL_WEAK + to check whether we have seen arguments. + * c-objc-common.c (c_tree_printer): Reverse order of tests so that + flag is checked before field (flag is common, field is not). + * dwarf2out.c (decl_ultimate_origin): Only DECL's with + TS_DECL_COMMON could have an origin. + (add_location_or_const_value_attribute): Don't check section name + on non-var/function decls. + (dwarf2out_var_location): Reverse order of tests. + * emit-rtl.c (set_reg_attrs_for_parm): DECL_CHECK is dead, replace + with DECL_WRTL_CHECK. + * expmed.c (make_tree): rtl is now in decl_with_rtl. + * fold-const.c (fold_binary): Don't check weakness on + non-var/function decls. + (tree_expr_nonzero_p): Ditto. + (fold_checksum_tree): Use tree_decl_extra as sizeof + buffer. + * ggc-page.c (extra_order_size_table): Add sizes for + tree_decl_non_common, tree_parm_decl, tree_var_decl, and + tree_field_decl. + * gimplify.c (gimplify_bind_expr): Only set + DECL_SEEN_IN_BIND_EXPR_P on VAR_DECL. + * integrate.c (copy_decl_for_inlining): Don't set RTL on decl's + without RTL. + * langhooks-def.h (LANG_HOOK_INIT_TS): New. + * langhooks.h (init_ts). New langhook. + * passes.c (rest_of_decl_compilation): Reverse order of tests. + * print-tree.c (print_node): Update to only print fields that + exist in the structures the passed decl has. + * toplev.c (wrapup_global_declarations): Don't reset + DECL_DEFER_OUTPUT on DECL's that don't contain it. + * tree-browser.c (browse_tree): DECL_ARG_TYPE_AS_WRITTEN removed. + * tree-inline.c (remap_decl): Ditto. + * tree-outof-ssa.c (create_temp): Reverse order of tests. + * tree-pretty-print.c (print_declaration): Don't print + DECL_REGISTER on things that don't contain it. + * tree-vrp.c (expr_computes_nonzero): Don't check weakness on + non-var/function decls. + * tree.c (tree_contains_struct): New structure. + (init_priority_for_decl): New hashtable. + (tree_int_map): New structure. + (tree_int_map_eq): New function. + (tree_int_map_marked_p): Ditto. + (tree_int_map_hash): Ditto. + (tree_map): Move to tree.h. + (tree_map_eq): Externalize. + (tree_map_hash): Ditto. + (tree_map_marked_p): Ditto. + (init_ttree): Set up tree_contains_struct and call langhook. + (decl_assembler_name): Use DECL_NON_COMMON_CHECK.. + (tree_code_size): Update for new structures. + (tree_node_structure): Update for new structures. + (make_node_stat): Don't try to set DECL_IN_SYSTEM_HEADER on decls + without the field. + (copy_node_stat): Copy init priority. + (build_decl_stat): Ditto for visibility. + (ts_enum_names): New. + (tree_contains_struct_check_failed): New function. + (decl_init_priority_lookup): Ditto. + (decl_init_priority_insert): Ditto. + * treestruct.def: New file. + * tree.h (CODE_CONTAINS_STRUCT): New macro. + (CONTAINS_STRUCT_CHECK): Ditto. + (tree_contains_struct_check_failed): New prototype. + (DECL_CHECK): Removed. + (DECL_MINIMAL_CHECK): New. + (DECL_COMMON_CHECK): Ditto. + (DECL_WRTL_CHECK): Ditto. + (DECL_NON_COMMON_CHECK): Ditto. + (DECL_WITH_VIS_CHECK): Ditto. + (VAR_OR_FUNCTION_DECL_P): Ditto + (struct tree_decl_minimal): New structure. + (struct tree_decl_common): Ditto. + (struct tree_decl_with_rtl): Ditto. + (struct tree_decl_with_vis): Ditto. + (struct tree_decl_non_common): Ditto. + (struct tree_field_decl): Ditto. + (struct tree_parm_decl): Ditto. + (struct tree_var_decl): Ditto. + (struct tree_function_decl): Ditto. + (struct tree_const_decl): Ditto. + (struct tree_result_decl): Ditto. + (union tree_node): Add new structures. + * var-tracking.c (track_expr_p): Reverse order of tests. + + * doc/c-tree.texi: Add documentation on DECL node internal structure. + 2005-07-08 Kazu Hirata <kazu@codesourcery.com> * cfgexpand.c (tree_expand_cfg): Don't use FINALIZE_PIC. diff --git a/gcc/Makefile.in b/gcc/Makefile.in index fe39901235a..244643cd531 100644 --- a/gcc/Makefile.in +++ b/gcc/Makefile.in @@ -711,7 +711,7 @@ RTL_BASE_H = rtl.h rtl.def $(MACHMODE_H) reg-notes.def insn-notes.def \ RTL_H = $(RTL_BASE_H) genrtl.h PARAMS_H = params.h params.def TREE_H = tree.h tree.def $(MACHMODE_H) tree-check.h builtins.def \ - input.h statistics.h vec.h + input.h statistics.h vec.h treestruct.def BASIC_BLOCK_H = basic-block.h bitmap.h sbitmap.h varray.h $(PARTITION_H) \ hard-reg-set.h cfghooks.h $(OBSTACK_H) GCOV_IO_H = gcov-io.h gcov-iov.h auto-host.h @@ -1457,7 +1457,8 @@ c-decl.o : c-decl.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H) \ $(EXPR_H) debug.h toplev.h intl.h $(TM_P_H) tree-inline.h $(TIMEVAR_H) \ opts.h $(C_PRAGMA_H) gt-c-decl.h $(CGRAPH_H) $(HASHTAB_H) libfuncs.h \ except.h $(LANGHOOKS_DEF_H) $(TREE_DUMP_H) $(C_COMMON_H) $(CPPLIB_H) \ - $(DIAGNOSTIC_H) input.h langhooks.h $(TREE_GIMPLE_H) tree-mudflap.h + $(DIAGNOSTIC_H) input.h langhooks.h $(TREE_GIMPLE_H) tree-mudflap.h \ + pointer-set.h c-typeck.o : c-typeck.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \ $(TREE_H) $(C_TREE_H) $(TARGET_H) $(FLAGS_H) intl.h output.h $(EXPR_H) \ $(RTL_H) toplev.h $(TM_P_H) langhooks.h $(GGC_H) $(TREE_FLOW_H) \ diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 1d6ab65eb7a..de7f06cf4d2 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,8 @@ +2005-07-08 Daniel Berlin <dberlin@dberlin.org> + + * utils.c (create_param_decl): DECL_ARG_TYPE_AS_WRITTEN is + removed. + 2005-07-07 Pascal Obry <obry@adacore.com> * g-socthi-mingw.adb (C_Inet_Addr): New body used to convert the diff --git a/gcc/ada/utils.c b/gcc/ada/utils.c index b19cb45f67f..ab86a490fb8 100644 --- a/gcc/ada/utils.c +++ b/gcc/ada/utils.c @@ -1494,7 +1494,6 @@ create_param_decl (tree param_name, tree param_type, bool readonly) } DECL_ARG_TYPE (param_decl) = param_type; - DECL_ARG_TYPE_AS_WRITTEN (param_decl) = param_type; TREE_READONLY (param_decl) = readonly; return param_decl; } diff --git a/gcc/c-decl.c b/gcc/c-decl.c index 23ff373ed0d..67c72a58d8c 100644 --- a/gcc/c-decl.c +++ b/gcc/c-decl.c @@ -60,6 +60,7 @@ Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA #include "libfuncs.h" #include "except.h" #include "langhooks-def.h" +#include "pointer-set.h" /* In grokdeclarator, distinguish syntactic contexts of declarators. */ enum decl_context @@ -1471,7 +1472,8 @@ diagnose_mismatched_decls (tree newdecl, tree olddecl, /* warnings */ /* All decls must agree on a visibility. */ - if (DECL_VISIBILITY_SPECIFIED (newdecl) && DECL_VISIBILITY_SPECIFIED (olddecl) + if (CODE_CONTAINS_STRUCT (TREE_CODE (newdecl), TS_DECL_WITH_VIS) + && DECL_VISIBILITY_SPECIFIED (newdecl) && DECL_VISIBILITY_SPECIFIED (olddecl) && DECL_VISIBILITY (newdecl) != DECL_VISIBILITY (olddecl)) { warning (0, "redeclaration of %q+D with different visibility " @@ -1638,8 +1640,6 @@ merge_decls (tree newdecl, tree olddecl, tree newtype, tree oldtype) } } - /* Keep the old rtl since we can safely use it. */ - COPY_DECL_RTL (olddecl, newdecl); /* Merge the type qualifiers. */ if (TREE_READONLY (newdecl)) @@ -1674,153 +1674,178 @@ merge_decls (tree newdecl, tree olddecl, tree newtype, tree oldtype) if (DECL_INITIAL (newdecl) == 0) DECL_INITIAL (newdecl) = DECL_INITIAL (olddecl); - /* Merge the section attribute. - We want to issue an error if the sections conflict but that must be - done later in decl_attributes since we are called before attributes - are assigned. */ - if (DECL_SECTION_NAME (newdecl) == NULL_TREE) - DECL_SECTION_NAME (newdecl) = DECL_SECTION_NAME (olddecl); - - /* Copy the assembler name. - Currently, it can only be defined in the prototype. */ - COPY_DECL_ASSEMBLER_NAME (olddecl, newdecl); - - /* Use visibility of whichever declaration had it specified */ - if (DECL_VISIBILITY_SPECIFIED (olddecl)) - { - DECL_VISIBILITY (newdecl) = DECL_VISIBILITY (olddecl); - DECL_VISIBILITY_SPECIFIED (newdecl) = 1; - } - - if (TREE_CODE (newdecl) == FUNCTION_DECL) - { - DECL_STATIC_CONSTRUCTOR(newdecl) |= DECL_STATIC_CONSTRUCTOR(olddecl); - DECL_STATIC_DESTRUCTOR (newdecl) |= DECL_STATIC_DESTRUCTOR (olddecl); - DECL_NO_LIMIT_STACK (newdecl) |= DECL_NO_LIMIT_STACK (olddecl); - DECL_NO_INSTRUMENT_FUNCTION_ENTRY_EXIT (newdecl) - |= DECL_NO_INSTRUMENT_FUNCTION_ENTRY_EXIT (olddecl); - TREE_THIS_VOLATILE (newdecl) |= TREE_THIS_VOLATILE (olddecl); - TREE_READONLY (newdecl) |= TREE_READONLY (olddecl); - DECL_IS_MALLOC (newdecl) |= DECL_IS_MALLOC (olddecl); - DECL_IS_PURE (newdecl) |= DECL_IS_PURE (olddecl); - DECL_IS_NOVOPS (newdecl) |= DECL_IS_NOVOPS (olddecl); - } - - /* Merge the storage class information. */ - merge_weak (newdecl, olddecl); - - /* For functions, static overrides non-static. */ - if (TREE_CODE (newdecl) == FUNCTION_DECL) - { - TREE_PUBLIC (newdecl) &= TREE_PUBLIC (olddecl); - /* This is since we don't automatically - copy the attributes of NEWDECL into OLDDECL. */ - TREE_PUBLIC (olddecl) = TREE_PUBLIC (newdecl); - /* If this clears `static', clear it in the identifier too. */ - if (!TREE_PUBLIC (olddecl)) - TREE_PUBLIC (DECL_NAME (olddecl)) = 0; - } - if (DECL_EXTERNAL (newdecl)) - { - TREE_STATIC (newdecl) = TREE_STATIC (olddecl); - DECL_EXTERNAL (newdecl) = DECL_EXTERNAL (olddecl); - - /* An extern decl does not override previous storage class. */ - TREE_PUBLIC (newdecl) = TREE_PUBLIC (olddecl); - if (!DECL_EXTERNAL (newdecl)) - { - DECL_CONTEXT (newdecl) = DECL_CONTEXT (olddecl); - DECL_COMMON (newdecl) = DECL_COMMON (olddecl); - } - } - else - { - TREE_STATIC (olddecl) = TREE_STATIC (newdecl); - TREE_PUBLIC (olddecl) = TREE_PUBLIC (newdecl); - } - - if (TREE_CODE (newdecl) == FUNCTION_DECL) - { - /* If we're redefining a function previously defined as extern - inline, make sure we emit debug info for the inline before we - throw it away, in case it was inlined into a function that hasn't - been written out yet. */ - if (new_is_definition && DECL_INITIAL (olddecl)) - { - if (TREE_USED (olddecl) - /* In unit-at-a-time mode we never inline re-defined extern - inline functions. */ - && !flag_unit_at_a_time - && cgraph_function_possibly_inlined_p (olddecl)) - (*debug_hooks->outlining_inline_function) (olddecl); - - /* The new defn must not be inline. */ - DECL_INLINE (newdecl) = 0; - DECL_UNINLINABLE (newdecl) = 1; - } - else - { - /* If either decl says `inline', this fn is inline, - unless its definition was passed already. */ - if (DECL_DECLARED_INLINE_P (newdecl) - || DECL_DECLARED_INLINE_P (olddecl)) - DECL_DECLARED_INLINE_P (newdecl) = 1; - - DECL_UNINLINABLE (newdecl) = DECL_UNINLINABLE (olddecl) - = (DECL_UNINLINABLE (newdecl) || DECL_UNINLINABLE (olddecl)); - } + if (CODE_CONTAINS_STRUCT (TREE_CODE (olddecl), TS_DECL_WITH_VIS)) + { + /* Merge the section attribute. + We want to issue an error if the sections conflict but that must be + done later in decl_attributes since we are called before attributes + are assigned. */ + if (DECL_SECTION_NAME (newdecl) == NULL_TREE) + DECL_SECTION_NAME (newdecl) = DECL_SECTION_NAME (olddecl); + + /* Copy the assembler name. + Currently, it can only be defined in the prototype. */ + COPY_DECL_ASSEMBLER_NAME (olddecl, newdecl); + + /* Use visibility of whichever declaration had it specified */ + if (DECL_VISIBILITY_SPECIFIED (olddecl)) + { + DECL_VISIBILITY (newdecl) = DECL_VISIBILITY (olddecl); + DECL_VISIBILITY_SPECIFIED (newdecl) = 1; + } + + if (TREE_CODE (newdecl) == FUNCTION_DECL) + { + DECL_STATIC_CONSTRUCTOR(newdecl) |= DECL_STATIC_CONSTRUCTOR(olddecl); + DECL_STATIC_DESTRUCTOR (newdecl) |= DECL_STATIC_DESTRUCTOR (olddecl); + DECL_NO_LIMIT_STACK (newdecl) |= DECL_NO_LIMIT_STACK (olddecl); + DECL_NO_INSTRUMENT_FUNCTION_ENTRY_EXIT (newdecl) + |= DECL_NO_INSTRUMENT_FUNCTION_ENTRY_EXIT (olddecl); + TREE_THIS_VOLATILE (newdecl) |= TREE_THIS_VOLATILE (olddecl); + TREE_READONLY (newdecl) |= TREE_READONLY (olddecl); + DECL_IS_MALLOC (newdecl) |= DECL_IS_MALLOC (olddecl); + DECL_IS_PURE (newdecl) |= DECL_IS_PURE (olddecl); + DECL_IS_NOVOPS (newdecl) |= DECL_IS_NOVOPS (olddecl); + } + + /* Merge the storage class information. */ + merge_weak (newdecl, olddecl); - if (DECL_BUILT_IN (olddecl)) - { - /* If redeclaring a builtin function, it stays built in. - But it gets tagged as having been declared. */ - DECL_BUILT_IN_CLASS (newdecl) = DECL_BUILT_IN_CLASS (olddecl); - DECL_FUNCTION_CODE (newdecl) = DECL_FUNCTION_CODE (olddecl); - C_DECL_DECLARED_BUILTIN (newdecl) = 1; - if (new_is_prototype) - C_DECL_BUILTIN_PROTOTYPE (newdecl) = 0; - else - C_DECL_BUILTIN_PROTOTYPE (newdecl) - = C_DECL_BUILTIN_PROTOTYPE (olddecl); - } + /* For functions, static overrides non-static. */ + if (TREE_CODE (newdecl) == FUNCTION_DECL) + { + TREE_PUBLIC (newdecl) &= TREE_PUBLIC (olddecl); + /* This is since we don't automatically + copy the attributes of NEWDECL into OLDDECL. */ + TREE_PUBLIC (olddecl) = TREE_PUBLIC (newdecl); + /* If this clears `static', clear it in the identifier too. */ + if (!TREE_PUBLIC (olddecl)) + TREE_PUBLIC (DECL_NAME (olddecl)) = 0; + } + } + + if (DECL_EXTERNAL (newdecl)) + { + TREE_STATIC (newdecl) = TREE_STATIC (olddecl); + DECL_EXTERNAL (newdecl) = DECL_EXTERNAL (olddecl); + + /* An extern decl does not override previous storage class. */ + TREE_PUBLIC (newdecl) = TREE_PUBLIC (olddecl); + if (!DECL_EXTERNAL (newdecl)) + { + DECL_CONTEXT (newdecl) = DECL_CONTEXT (olddecl); + DECL_COMMON (newdecl) = DECL_COMMON (olddecl); + } + } + else + { + TREE_STATIC (olddecl) = TREE_STATIC (newdecl); + TREE_PUBLIC (olddecl) = TREE_PUBLIC (newdecl); + } + + if (TREE_CODE (newdecl) == FUNCTION_DECL) + { + /* If we're redefining a function previously defined as extern + inline, make sure we emit debug info for the inline before we + throw it away, in case it was inlined into a function that hasn't + been written out yet. */ + if (new_is_definition && DECL_INITIAL (olddecl)) + { + if (TREE_USED (olddecl) + /* In unit-at-a-time mode we never inline re-defined extern + inline functions. */ + && !flag_unit_at_a_time + && cgraph_function_possibly_inlined_p (olddecl)) + (*debug_hooks->outlining_inline_function) (olddecl); + + /* The new defn must not be inline. */ + DECL_INLINE (newdecl) = 0; + DECL_UNINLINABLE (newdecl) = 1; + } + else + { + /* If either decl says `inline', this fn is inline, + unless its definition was passed already. */ + if (DECL_DECLARED_INLINE_P (newdecl) + || DECL_DECLARED_INLINE_P (olddecl)) + DECL_DECLARED_INLINE_P (newdecl) = 1; + + DECL_UNINLINABLE (newdecl) = DECL_UNINLINABLE (olddecl) + = (DECL_UNINLINABLE (newdecl) || DECL_UNINLINABLE (olddecl)); + } - /* Also preserve various other info from the definition. */ - if (!new_is_definition) - { - DECL_RESULT (newdecl) = DECL_RESULT (olddecl); - DECL_INITIAL (newdecl) = DECL_INITIAL (olddecl); - DECL_STRUCT_FUNCTION (newdecl) = DECL_STRUCT_FUNCTION (olddecl); - DECL_SAVED_TREE (newdecl) = DECL_SAVED_TREE (olddecl); - DECL_ARGUMENTS (newdecl) = DECL_ARGUMENTS (olddecl); - - /* Set DECL_INLINE on the declaration if we've got a body - from which to instantiate. */ - if (DECL_INLINE (olddecl) && !DECL_UNINLINABLE (newdecl)) - { - DECL_INLINE (newdecl) = 1; - DECL_ABSTRACT_ORIGIN (newdecl) - = DECL_ABSTRACT_ORIGIN (olddecl); - } - } - else - { - /* If a previous declaration said inline, mark the - definition as inlinable. */ - if (DECL_DECLARED_INLINE_P (newdecl) - && !DECL_UNINLINABLE (newdecl)) - DECL_INLINE (newdecl) = 1; - } - } + if (DECL_BUILT_IN (olddecl)) + { + /* If redeclaring a builtin function, it stays built in. + But it gets tagged as having been declared. */ + DECL_BUILT_IN_CLASS (newdecl) = DECL_BUILT_IN_CLASS (olddecl); + DECL_FUNCTION_CODE (newdecl) = DECL_FUNCTION_CODE (olddecl); + C_DECL_DECLARED_BUILTIN (newdecl) = 1; + if (new_is_prototype) + C_DECL_BUILTIN_PROTOTYPE (newdecl) = 0; + else + C_DECL_BUILTIN_PROTOTYPE (newdecl) + = C_DECL_BUILTIN_PROTOTYPE (olddecl); + } - /* Copy most of the decl-specific fields of NEWDECL into OLDDECL. + /* Also preserve various other info from the definition. */ + if (!new_is_definition) + { + DECL_RESULT (newdecl) = DECL_RESULT (olddecl); + DECL_INITIAL (newdecl) = DECL_INITIAL (olddecl); + DECL_STRUCT_FUNCTION (newdecl) = DECL_STRUCT_FUNCTION (olddecl); + DECL_SAVED_TREE (newdecl) = DECL_SAVED_TREE (olddecl); + DECL_ARGUMENTS (newdecl) = DECL_ARGUMENTS (olddecl); + + /* Set DECL_INLINE on the declaration if we've got a body + from which to instantiate. */ + if (DECL_INLINE (olddecl) && !DECL_UNINLINABLE (newdecl)) + { + DECL_INLINE (newdecl) = 1; + DECL_ABSTRACT_ORIGIN (newdecl) + = DECL_ABSTRACT_ORIGIN (olddecl); + } + } + else + { + /* If a previous declaration said inline, mark the + definition as inlinable. */ + if (DECL_DECLARED_INLINE_P (newdecl) + && !DECL_UNINLINABLE (newdecl)) + DECL_INLINE (newdecl) = 1; + } + } + + /* Copy most of the decl-specific fields of NEWDECL into OLDDECL. But preserve OLDDECL's DECL_UID and DECL_CONTEXT. */ { unsigned olddecl_uid = DECL_UID (olddecl); tree olddecl_context = DECL_CONTEXT (olddecl); - + memcpy ((char *) olddecl + sizeof (struct tree_common), (char *) newdecl + sizeof (struct tree_common), - sizeof (struct tree_decl) - sizeof (struct tree_common)); + sizeof (struct tree_decl_common) - sizeof (struct tree_common)); + switch (TREE_CODE (olddecl)) + { + case FIELD_DECL: + case VAR_DECL: + case PARM_DECL: + case LABEL_DECL: + case RESULT_DECL: + case CONST_DECL: + case TYPE_DECL: + case FUNCTION_DECL: + memcpy ((char *) olddecl + sizeof (struct tree_decl_common), + (char *) newdecl + sizeof (struct tree_decl_common), + tree_code_size (TREE_CODE (olddecl)) - sizeof (struct tree_decl_common)); + break; + + default: + + memcpy ((char *) olddecl + sizeof (struct tree_decl_common), + (char *) newdecl + sizeof (struct tree_decl_common), + sizeof (struct tree_decl_non_common) - sizeof (struct tree_decl_common)); + } DECL_UID (olddecl) = olddecl_uid; DECL_CONTEXT (olddecl) = olddecl_context; } @@ -4475,7 +4500,6 @@ grokdeclarator (const struct c_declarator *declarator, promoted_type = c_type_promotes_to (type); DECL_ARG_TYPE (decl) = promoted_type; - DECL_ARG_TYPE_AS_WRITTEN (decl) = type_as_written; if (declspecs->inline_p) pedwarn ("parameter %q+D declared %<inline%>", decl); } @@ -4680,8 +4704,11 @@ grokdeclarator (const struct c_declarator *declarator, /* If a type has volatile components, it should be stored in memory. Otherwise, the fact that those components are volatile - will be ignored, and would even crash the compiler. */ - if (C_TYPE_FIELDS_VOLATILE (TREE_TYPE (decl))) + will be ignored, and would even crash the compiler. + Of course, this only makes sense on VAR,PARM, and RESULT decl's. */ + if (C_TYPE_FIELDS_VOLATILE (TREE_TYPE (decl)) + && (TREE_CODE (decl) == VAR_DECL || TREE_CODE (decl) == PARM_DECL + || TREE_CODE (decl) == RESULT_DECL)) { /* It is not an error for a structure with volatile fields to be declared register, but reset DECL_REGISTER since it @@ -6088,13 +6115,7 @@ store_parm_decls_oldstyle (tree fndecl, const struct c_arg_info *arg_info) struct c_binding *b; tree parm, decl, last; tree parmids = arg_info->parms; - - /* We use DECL_WEAK as a flag to show which parameters have been - seen already, since it is not used on PARM_DECL. */ -#ifdef ENABLE_CHECKING - for (b = current_scope->bindings; b; b = b->prev) - gcc_assert (TREE_CODE (b->decl) != PARM_DECL || !DECL_WEAK (b->decl)); -#endif + struct pointer_set_t *seen_args = pointer_set_create (); if (!in_system_header) warning (OPT_Wold_style_definition, "%Jold-style function definition", @@ -6120,7 +6141,7 @@ store_parm_decls_oldstyle (tree fndecl, const struct c_arg_info *arg_info) error ("%q+D declared as a non-parameter", decl); /* If the declaration is already marked, we have a duplicate name. Complain and ignore the duplicate. */ - else if (DECL_WEAK (decl)) + else if (pointer_set_contains (seen_args, decl)) { error ("multiple parameters named %q+D", decl); TREE_PURPOSE (parm) = 0; @@ -6151,7 +6172,7 @@ store_parm_decls_oldstyle (tree fndecl, const struct c_arg_info *arg_info) } TREE_PURPOSE (parm) = decl; - DECL_WEAK (decl) = 1; + pointer_set_insert (seen_args, decl); } /* Now examine the parms chain for incomplete declarations @@ -6170,7 +6191,7 @@ store_parm_decls_oldstyle (tree fndecl, const struct c_arg_info *arg_info) TREE_TYPE (parm) = error_mark_node; } - if (!DECL_WEAK (parm)) + if (!pointer_set_contains (seen_args, parm)) { error ("declaration for parameter %q+D but no such parameter", parm); @@ -6193,18 +6214,18 @@ store_parm_decls_oldstyle (tree fndecl, const struct c_arg_info *arg_info) { last = TREE_PURPOSE (parm); DECL_ARGUMENTS (fndecl) = last; - DECL_WEAK (last) = 0; for (parm = TREE_CHAIN (parm); parm; parm = TREE_CHAIN (parm)) if (TREE_PURPOSE (parm)) { TREE_CHAIN (last) = TREE_PURPOSE (parm); last = TREE_PURPOSE (parm); - DECL_WEAK (last) = 0; } TREE_CHAIN (last) = 0; } + pointer_set_destroy (seen_args); + /* If there was a previous prototype, set the DECL_ARG_TYPE of each argument according to the type previously specified, and report any mismatches. */ diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 9019b67f8c0..310d0425983 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,30 @@ +2005-07-08 Daniel Berlin <dberlin@dberlin.org> + + * Make-lang.in: Add gt-cp-lang.h. + (cp-lang.o): Ditto. + * class.c (create_vtable_ptr): Stop setting DECL_ASSEMBLER_NAME on + the field. + * config-lang.in: Add cp-lang.c to gtfiles. + * cp-lang.c: Include hashtab.h. + (cp_init_ts): New function. + (LANG_HOOK_INIT_TS): Use macro. + (decl_shadowed_for_var_lookup): New function. + (decl_shadowed_for_var_insert): Ditto. + * cp-tree.h (THUNK_FUNCTION_CHECK): Use decl_common. + (NON_THUNK_FUNCTION_CHECK): Ditto. + (DECL_NAMESPACE_ASSOCIATIONS): Use decl_non_common. + (DECL_INIT_PRIORITY): Ditto. + (DECL_HAS_SHADOWED_FOR_VAR_P): Ditto. + (DECL_SHADOWED_FOR_VAR): Use hashtable. + (SET_DECL_SHADOWED_FOR_VAR): Ditto. + * decl.c (duplicate_decls): Update for new/updated structures. + (poplevel): Use SET_DECL_SHADOWED_FOR_VAR. + * decl2.c (start_static_initialization_or_destruction): Deal with + priority. + * pt.c (tsubst_decl): Check TS_DECL_WRTL before doing + SET_DECL_RTL. + * tree.c (handle_init_priority_attribute): Handle priority. + 2005-07-08 Nathan Sidwell <nathan@codesourcery.com> PR c++/21799 diff --git a/gcc/cp/Make-lang.in b/gcc/cp/Make-lang.in index c3649e1ccc3..632e2abaffd 100644 --- a/gcc/cp/Make-lang.in +++ b/gcc/cp/Make-lang.in @@ -110,7 +110,7 @@ $(srcdir)/cp/cfns.h: $(srcdir)/cp/cfns.gperf $(srcdir)/cp/cfns.gperf > $(srcdir)/cp/cfns.h gtype-cp.h gt-cp-call.h gt-cp-decl.h gt-cp-decl2.h : s-gtype; @true -gt-cp-pt.h gt-cp-repo.h gt-cp-parser.h gt-cp-method.h : s-gtype; @true +gt-cp-pt.h gt-cp-repo.h gt-cp-parser.h gt-cp-method.h gt-cp-lang.h : s-gtype; @true gt-cp-tree.h gt-cp-mangle.h gt-cp-name-lookup.h gt-cp-typeck2.h: s-gtype; @true gt-cp-rtti.h: s-gtype ; @true @@ -237,7 +237,7 @@ cp/lex.o: cp/lex.c $(CXX_TREE_H) $(TM_H) flags.h \ c-pragma.h toplev.h output.h input.h cp/operators.def $(TM_P_H) cp/cp-lang.o: cp/cp-lang.c $(CXX_TREE_H) $(TM_H) toplev.h debug.h langhooks.h \ $(LANGHOOKS_DEF_H) c-common.h gtype-cp.h \ - $(DIAGNOSTIC_H) cp/cp-objcp-common.h + $(DIAGNOSTIC_H) cp/cp-objcp-common.h gt-cp-lang.h cp/decl.o: cp/decl.c $(CXX_TREE_H) $(TM_H) flags.h cp/decl.h \ output.h $(EXPR_H) except.h toplev.h $(HASHTAB_H) $(RTL_H) \ cp/operators.def $(TM_P_H) tree-inline.h diagnostic.h c-pragma.h \ diff --git a/gcc/cp/class.c b/gcc/cp/class.c index a226d28f885..5dbec4602a4 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -4130,7 +4130,6 @@ create_vtable_ptr (tree t, tree* virtuals_p) tree field; field = build_decl (FIELD_DECL, get_vfield_name (t), vtbl_ptr_type_node); - SET_DECL_ASSEMBLER_NAME (field, get_identifier (VFIELD_BASE)); DECL_VIRTUAL_P (field) = 1; DECL_ARTIFICIAL (field) = 1; DECL_FIELD_CONTEXT (field) = t; diff --git a/gcc/cp/config-lang.in b/gcc/cp/config-lang.in index de96c1c7265..dcf84ca2aed 100644 --- a/gcc/cp/config-lang.in +++ b/gcc/cp/config-lang.in @@ -34,4 +34,4 @@ stagestuff="g++\$(exeext) g++-cross\$(exeext) cc1plus\$(exeext)" target_libs="target-libstdc++-v3" -gtfiles="\$(srcdir)/cp/rtti.c \$(srcdir)/cp/mangle.c \$(srcdir)/cp/name-lookup.h \$(srcdir)/cp/name-lookup.c \$(srcdir)/cp/cp-tree.h \$(srcdir)/cp/decl.h \$(srcdir)/cp/call.c \$(srcdir)/cp/decl.c \$(srcdir)/cp/decl2.c \$(srcdir)/cp/pt.c \$(srcdir)/cp/repo.c \$(srcdir)/cp/semantics.c \$(srcdir)/cp/tree.c \$(srcdir)/cp/parser.c \$(srcdir)/cp/method.c \$(srcdir)/cp/typeck2.c \$(srcdir)/c-common.c \$(srcdir)/c-common.h \$(srcdir)/c-lex.c \$(srcdir)/c-pragma.c \$(srcdir)/cp/class.c" +gtfiles="\$(srcdir)/cp/rtti.c \$(srcdir)/cp/mangle.c \$(srcdir)/cp/name-lookup.h \$(srcdir)/cp/name-lookup.c \$(srcdir)/cp/cp-tree.h \$(srcdir)/cp/decl.h \$(srcdir)/cp/call.c \$(srcdir)/cp/decl.c \$(srcdir)/cp/decl2.c \$(srcdir)/cp/pt.c \$(srcdir)/cp/repo.c \$(srcdir)/cp/semantics.c \$(srcdir)/cp/tree.c \$(srcdir)/cp/parser.c \$(srcdir)/cp/method.c \$(srcdir)/cp/typeck2.c \$(srcdir)/c-common.c \$(srcdir)/c-common.h \$(srcdir)/c-lex.c \$(srcdir)/c-pragma.c \$(srcdir)/cp/class.c \$(srcdir)/cp/cp-lang.c" diff --git a/gcc/cp/cp-lang.c b/gcc/cp/cp-lang.c index 1806b47d741..1e3fb4d0195 100644 --- a/gcc/cp/cp-lang.c +++ b/gcc/cp/cp-lang.c @@ -32,8 +32,10 @@ Boston, MA 02110-1301, USA. */ #include "diagnostic.h" #include "debug.h" #include "cp-objcp-common.h" +#include "hashtab.h" enum c_language_kind c_language = clk_cxx; +static void cp_init_ts (void); /* Lang hooks common to C++ and ObjC++ are declared in cp/cp-objcp-common.h; consequently, there should be very few hooks below. */ @@ -46,6 +48,8 @@ enum c_language_kind c_language = clk_cxx; #define LANG_HOOKS_DECL_PRINTABLE_NAME cxx_printable_name #undef LANG_HOOKS_FOLD_OBJ_TYPE_REF #define LANG_HOOKS_FOLD_OBJ_TYPE_REF cp_fold_obj_type_ref +#undef LANG_HOOKS_INIT_TS +#define LANG_HOOKS_INIT_TS cp_init_ts /* Each front end provides its own lang hook initializer. */ const struct lang_hooks lang_hooks = LANG_HOOKS_INITIALIZER; @@ -106,10 +110,79 @@ objcp_tsubst_copy_and_build (tree t ATTRIBUTE_UNUSED, return NULL_TREE; } +static GTY ((if_marked ("tree_map_marked_p"), param_is (struct tree_map))) + htab_t shadowed_var_for_decl; + + +static void +cp_init_ts (void) +{ + tree_contains_struct[NAMESPACE_DECL][TS_DECL_NON_COMMON] = 1; + tree_contains_struct[USING_DECL][TS_DECL_NON_COMMON] = 1; + tree_contains_struct[TEMPLATE_DECL][TS_DECL_NON_COMMON] = 1; + tree_contains_struct[ALIAS_DECL][TS_DECL_NON_COMMON] = 1; + + tree_contains_struct[NAMESPACE_DECL][TS_DECL_WITH_VIS] = 1; + tree_contains_struct[USING_DECL][TS_DECL_WITH_VIS] = 1; + tree_contains_struct[TEMPLATE_DECL][TS_DECL_WITH_VIS] = 1; + tree_contains_struct[ALIAS_DECL][TS_DECL_WITH_VIS] = 1; + + tree_contains_struct[NAMESPACE_DECL][TS_DECL_WRTL] = 1; + tree_contains_struct[USING_DECL][TS_DECL_WRTL] = 1; + tree_contains_struct[TEMPLATE_DECL][TS_DECL_WRTL] = 1; + tree_contains_struct[ALIAS_DECL][TS_DECL_WRTL] = 1; + + tree_contains_struct[NAMESPACE_DECL][TS_DECL_COMMON] = 1; + tree_contains_struct[USING_DECL][TS_DECL_COMMON] = 1; + tree_contains_struct[TEMPLATE_DECL][TS_DECL_COMMON] = 1; + tree_contains_struct[ALIAS_DECL][TS_DECL_COMMON] = 1; + + tree_contains_struct[NAMESPACE_DECL][TS_DECL_MINIMAL] = 1; + tree_contains_struct[USING_DECL][TS_DECL_MINIMAL] = 1; + tree_contains_struct[TEMPLATE_DECL][TS_DECL_MINIMAL] = 1; + tree_contains_struct[ALIAS_DECL][TS_DECL_MINIMAL] = 1; + + shadowed_var_for_decl = htab_create_ggc (512, tree_map_hash, + tree_map_eq, 0); + +} + +/* Lookup a shadowed var for FROM, and return it if we find one. */ + +tree +decl_shadowed_for_var_lookup (tree from) +{ + struct tree_map *h, in; + in.from = from; + + h = htab_find_with_hash (shadowed_var_for_decl, &in, + htab_hash_pointer (from)); + if (h) + return h->to; + return NULL_TREE; +} + +/* Insert a mapping FROM->TO in the shadowed var hashtable. */ + +void +decl_shadowed_for_var_insert (tree from, tree to) +{ + struct tree_map *h; + void **loc; + + h = ggc_alloc (sizeof (struct tree_map)); + h->hash = htab_hash_pointer (from); + h->from = from; + h->to = to; + loc = htab_find_slot_with_hash (shadowed_var_for_decl, h, h->hash, INSERT); + *(struct tree_map **) loc = h; +} + void finish_file (void) { cp_finish_file (); } +#include "gt-cp-cp-lang.h" #include "gtype-cp.h" diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index 7edb1e639e4..b897ee26bec 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -174,15 +174,15 @@ struct diagnostic_context; #define NON_THUNK_FUNCTION_CHECK(NODE) __extension__ \ ({ const tree __t = (NODE); \ if (TREE_CODE (__t) != FUNCTION_DECL && \ - TREE_CODE (__t) != TEMPLATE_DECL && __t->decl.lang_specific \ - && __t->decl.lang_specific->decl_flags.thunk_p) \ + TREE_CODE (__t) != TEMPLATE_DECL && __t->decl_common.lang_specific \ + && __t->decl_common.lang_specific->decl_flags.thunk_p) \ tree_check_failed (__t, __FILE__, __LINE__, __FUNCTION__, 0); \ __t; }) #define THUNK_FUNCTION_CHECK(NODE) __extension__ \ ({ const tree __t = (NODE); \ - if (TREE_CODE (__t) != FUNCTION_DECL || !__t->decl.lang_specific \ - || !__t->decl.lang_specific->decl_flags.thunk_p) \ - tree_check_failed (__t, __FILE__, __LINE__, __FUNCTION__, 0); \ + if (TREE_CODE (__t) != FUNCTION_DECL || !__t->decl_common.lang_specific \ + || !__t->decl_common.lang_specific->decl_flags.thunk_p) \ + tree_check_failed (__t, __FILE__, __LINE__, __FUNCTION__, 0); \ __t; }) #else #define NON_THUNK_FUNCTION_CHECK(NODE) (NODE) @@ -1992,7 +1992,7 @@ struct lang_decl GTY(()) /* In a NAMESPACE_DECL, the list of namespaces which have associated themselves with this one. */ #define DECL_NAMESPACE_ASSOCIATIONS(NODE) \ - (NAMESPACE_DECL_CHECK (NODE)->decl.saved_tree) + (NAMESPACE_DECL_CHECK (NODE)->decl_non_common.saved_tree) /* In a NAMESPACE_DECL, points to the original namespace if this is a namespace alias. */ @@ -2007,15 +2007,13 @@ struct lang_decl GTY(()) && CP_DECL_CONTEXT (NODE) == global_namespace \ && DECL_NAME (NODE) == std_identifier) -/* In a non-local VAR_DECL with static storage duration, this is the - initialization priority. If this value is zero, the NODE will be - initialized at the DEFAULT_INIT_PRIORITY. */ -#define DECL_INIT_PRIORITY(NODE) (VAR_DECL_CHECK (NODE)->decl.u2.i) - /* In a TREE_LIST concatenating using directives, indicate indirect directives */ #define TREE_INDIRECT_USING(NODE) (TREE_LIST_CHECK (NODE)->common.lang_flag_0) +extern tree decl_shadowed_for_var_lookup (tree); +extern void decl_shadowed_for_var_insert (tree, tree); + /* Non zero if this is a using decl for a dependent scope. */ #define DECL_DEPENDENT_P(NODE) DECL_LANG_FLAG_0 (USING_DECL_CHECK (NODE)) @@ -2025,9 +2023,18 @@ struct lang_decl GTY(()) /* The decls named by a using decl. */ #define USING_DECL_DECLS(NODE) DECL_INITIAL (USING_DECL_CHECK (NODE)) +/* In a VAR_DECL, true if we have a shadowed local variable + in the shadowed var table for this VAR_DECL. */ +#define DECL_HAS_SHADOWED_FOR_VAR_P(NODE) \ + (VAR_DECL_CHECK (NODE)->decl_with_vis.shadowed_for_var_p) + /* In a VAR_DECL for a variable declared in a for statement, this is the shadowed (local) variable. */ -#define DECL_SHADOWED_FOR_VAR(NODE) DECL_RESULT_FLD(VAR_DECL_CHECK (NODE)) +#define DECL_SHADOWED_FOR_VAR(NODE) \ + (DECL_HAS_SHADOWED_FOR_VAR_P(NODE) ? decl_shadowed_for_var_lookup (NODE) : NULL) + +#define SET_DECL_SHADOWED_FOR_VAR(NODE, VAL) \ + (decl_shadowed_for_var_insert (NODE, VAL)) /* In a FUNCTION_DECL, this is nonzero if this function was defined in the class definition. We have saved away the text of the function, @@ -2300,7 +2307,7 @@ struct lang_decl GTY(()) /* Nonzero if NODE is a FUNCTION_DECL for a built-in function, and we have not yet seen a prototype for that function. */ #define DECL_ANTICIPATED(NODE) \ - (DECL_LANG_SPECIFIC (DECL_CHECK (NODE))->decl_flags.anticipated_p) + (DECL_LANG_SPECIFIC (DECL_COMMON_CHECK (NODE))->decl_flags.anticipated_p) /* Record whether a typedef for type `int' was actually `signed int'. */ #define C_TYPEDEF_EXPLICITLY_SIGNED(EXP) DECL_LANG_FLAG_1 (EXP) @@ -2622,7 +2629,7 @@ struct lang_decl GTY(()) TEMPLATE_PARM_INDEX for the parameter is available as the DECL_INITIAL (for a PARM_DECL) or as the TREE_TYPE (for a TYPE_DECL). */ -#define DECL_TEMPLATE_PARMS(NODE) DECL_ARGUMENTS (NODE) +#define DECL_TEMPLATE_PARMS(NODE) DECL_NON_COMMON_CHECK (NODE)->decl_non_common.arguments #define DECL_INNERMOST_TEMPLATE_PARMS(NODE) \ INNERMOST_TEMPLATE_PARMS (DECL_TEMPLATE_PARMS (NODE)) #define DECL_NTPARMS(NODE) \ diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 6e1dad10867..ee6a89b71f6 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -608,7 +608,10 @@ poplevel (int keep, int reverse, int functionbody) /* Keep track of what should have happened when we popped the binding. */ if (ob && ob->value) - DECL_SHADOWED_FOR_VAR (link) = ob->value; + { + SET_DECL_SHADOWED_FOR_VAR (link, ob->value); + DECL_HAS_SHADOWED_FOR_VAR_P (link) = 1; + } /* Add it to the list of dead variables in the next outermost binding to that we can remove these when we @@ -1805,6 +1808,13 @@ duplicate_decls (tree newdecl, tree olddecl) DECL_VISIBILITY (newdecl) = DECL_VISIBILITY (olddecl); DECL_VISIBILITY_SPECIFIED (newdecl) = 1; } + /* Init priority used to be merged from newdecl to olddecl by the memcpy, + so keep this behavior. */ + if (TREE_CODE (newdecl) == VAR_DECL && DECL_HAS_INIT_PRIORITY_P (newdecl)) + { + SET_DECL_INIT_PRIORITY (olddecl, DECL_INIT_PRIORITY (newdecl)); + DECL_HAS_INIT_PRIORITY_P (olddecl) = 1; + } /* The DECL_LANG_SPECIFIC information in OLDDECL will be replaced with that from NEWDECL below. */ @@ -1819,12 +1829,15 @@ duplicate_decls (tree newdecl, tree olddecl) { int function_size; - function_size = sizeof (struct tree_decl); + function_size = sizeof (struct tree_decl_common); memcpy ((char *) olddecl + sizeof (struct tree_common), (char *) newdecl + sizeof (struct tree_common), function_size - sizeof (struct tree_common)); + memcpy ((char *) olddecl + sizeof (struct tree_decl_common), + (char *) newdecl + sizeof (struct tree_decl_common), + sizeof (struct tree_function_decl) - sizeof (struct tree_decl_common)); if (DECL_TEMPLATE_INSTANTIATION (newdecl)) /* If newdecl is a template instantiation, it is possible that the following sequence of events has occurred: @@ -1853,12 +1866,34 @@ duplicate_decls (tree newdecl, tree olddecl) } else { + size_t size = tree_code_size (TREE_CODE (olddecl)); memcpy ((char *) olddecl + sizeof (struct tree_common), (char *) newdecl + sizeof (struct tree_common), - sizeof (struct tree_decl) - sizeof (struct tree_common) - + TREE_CODE_LENGTH (TREE_CODE (newdecl)) * sizeof (char *)); + sizeof (struct tree_decl_common) - sizeof (struct tree_common)); + switch (TREE_CODE (olddecl)) + { + case LABEL_DECL: + case VAR_DECL: + case RESULT_DECL: + case PARM_DECL: + case FIELD_DECL: + case TYPE_DECL: + case CONST_DECL: + { + memcpy ((char *) olddecl + sizeof (struct tree_decl_common), + (char *) newdecl + sizeof (struct tree_decl_common), + size - sizeof (struct tree_decl_common) + + TREE_CODE_LENGTH (TREE_CODE (newdecl)) * sizeof (char *)); + } + break; + default: + memcpy ((char *) olddecl + sizeof (struct tree_decl_common), + (char *) newdecl + sizeof (struct tree_decl_common), + sizeof (struct tree_decl_non_common) - sizeof (struct tree_decl_common) + + TREE_CODE_LENGTH (TREE_CODE (newdecl)) * sizeof (char *)); + break; + } } - DECL_UID (olddecl) = olddecl_uid; if (olddecl_friend) DECL_FRIEND_P (olddecl) = 1; diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c index cb08ee51eeb..22166e8b398 100644 --- a/gcc/cp/decl2.c +++ b/gcc/cp/decl2.c @@ -2321,14 +2321,15 @@ static tree start_static_initialization_or_destruction (tree decl, int initp) { tree guard_if_stmt = NULL_TREE; - int priority; + int priority = 0; tree cond; tree guard; tree init_cond; priority_info pi; - /* Figure out the priority for this declaration. */ - priority = DECL_INIT_PRIORITY (decl); + /* Figure out the priority for this declaration. */ + if (DECL_HAS_INIT_PRIORITY_P (decl)) + priority = DECL_INIT_PRIORITY (decl); if (!priority) priority = DEFAULT_INIT_PRIORITY; diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c index d03fbb0462e..4e2812811c8 100644 --- a/gcc/cp/name-lookup.c +++ b/gcc/cp/name-lookup.c @@ -1081,10 +1081,12 @@ check_for_out_of_scope_variable (tree decl) if (!(TREE_CODE (decl) == VAR_DECL && DECL_DEAD_FOR_LOCAL (decl))) return decl; - shadowed = DECL_SHADOWED_FOR_VAR (decl); + shadowed = DECL_HAS_SHADOWED_FOR_VAR_P (decl) + ? DECL_SHADOWED_FOR_VAR (decl) : NULL_TREE ; while (shadowed != NULL_TREE && TREE_CODE (shadowed) == VAR_DECL && DECL_DEAD_FOR_LOCAL (shadowed)) - shadowed = DECL_SHADOWED_FOR_VAR (shadowed); + shadowed = DECL_HAS_SHADOWED_FOR_VAR_P (shadowed) + ? DECL_SHADOWED_FOR_VAR (shadowed) : NULL_TREE; if (!shadowed) shadowed = IDENTIFIER_NAMESPACE_VALUE (DECL_NAME (decl)); if (shadowed) diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 7424e9dfc83..0fcb5e85a54 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -2251,9 +2251,10 @@ reduce_template_parm_level (tree index, tree type, int levels) decl, type); TEMPLATE_PARM_DESCENDANTS (index) = t; - /* Template template parameters need this. */ - DECL_TEMPLATE_PARMS (decl) - = DECL_TEMPLATE_PARMS (TEMPLATE_PARM_DECL (index)); + /* Template template parameters need this. */ + if (TREE_CODE (decl) != CONST_DECL) + DECL_TEMPLATE_PARMS (decl) + = DECL_TEMPLATE_PARMS (TEMPLATE_PARM_DECL (index)); } return TEMPLATE_PARM_DESCENDANTS (index); @@ -6646,12 +6647,14 @@ tsubst_decl (tree t, tree args, tsubst_flags_t complain) DECL_CONTEXT (r) = ctx; /* Clear out the mangled name and RTL for the instantiation. */ SET_DECL_ASSEMBLER_NAME (r, NULL_TREE); - SET_DECL_RTL (r, NULL_RTX); + if (CODE_CONTAINS_STRUCT (TREE_CODE (t), TS_DECL_WRTL)) + SET_DECL_RTL (r, NULL_RTX); /* Don't try to expand the initializer until someone tries to use this variable; otherwise we run into circular dependencies. */ DECL_INITIAL (r) = NULL_TREE; - SET_DECL_RTL (r, NULL_RTX); + if (CODE_CONTAINS_STRUCT (TREE_CODE (t), TS_DECL_WRTL)) + SET_DECL_RTL (r, NULL_RTX); DECL_SIZE (r) = DECL_SIZE_UNIT (r) = 0; /* Even if the original location is out of scope, the newly diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index 4a1784a25d2..e0eb1ac6ef7 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -1841,7 +1841,8 @@ handle_init_priority_attribute (tree* node, if (SUPPORTS_INIT_PRIORITY) { - DECL_INIT_PRIORITY (decl) = pri; + SET_DECL_INIT_PRIORITY (decl, pri); + DECL_HAS_INIT_PRIORITY_P (decl) = 1; return NULL_TREE; } else @@ -2128,7 +2129,7 @@ decl_linkage (tree decl) template instantiations have internal linkage (in the object file), but the symbols should still be treated as having external linkage from the point of view of the language. */ - if (DECL_LANG_SPECIFIC (decl) && DECL_COMDAT (decl)) + if (TREE_CODE (decl) != TYPE_DECL && DECL_LANG_SPECIFIC (decl) && DECL_COMDAT (decl)) return lk_external; /* Things in local scope do not have linkage, if they don't have diff --git a/gcc/doc/c-tree.texi b/gcc/doc/c-tree.texi index 196aa564430..fc00d82afb0 100644 --- a/gcc/doc/c-tree.texi +++ b/gcc/doc/c-tree.texi @@ -847,6 +847,15 @@ internal representation, except for declarations of functions (represented by @code{FUNCTION_DECL} nodes), which are described in @ref{Functions}. +@menu +* Working with declarations:: Macros and functions that work on +declarations. +* Internal structure:: How declaration nodes are represented. +@end menu + +@node Working with declarations +@subsection Working with declarations + Some macros can be used with any kind of declaration. These include: @ftable @code @item DECL_NAME @@ -991,6 +1000,179 @@ Back ends can safely ignore these nodes. @end table +@node Internal structure +@subsection Internal structure + +@code{DECL} nodes are represented internally as a hierarchy of +structures. + +@menu +* Current structure hierarchy:: The current DECL node structure +hierarchy. +* Adding new DECL node types:: How to add a new DECL node to a +frontend. +@end menu + +@node Current structure hierarchy +@subsubsection Current structure hierarchy + +@table @code + +@item struct tree_decl_minimal +This is the minimal structure to inherit from in order for common +@code{DECL} macros to work. The fields it contains are a unique ID, +source location, context, and name. + +@item struct tree_decl_common +This structure inherits from @code{struct tree_decl_minimal}. It +contains fields that most @code{DECL} nodes need, such as a field to +store alignment, machine mode, size, and attributes. + +@item struct tree_field_decl +This structure inherits from @code{struct tree_decl_common}. It is +used to represent @code{FIELD_DECL}. + +@item struct tree_label_decl +This structure inherits from @code{struct tree_decl_common}. It is +used to represent @code{LABEL_DECL}. + +@item struct tree_translation_unit_decl +This structure inherits from @code{struct tree_decl_common}. It is +used to represent @code{TRANSLATION_UNIT_DECL}. + +@item struct tree_decl_with_rtl +This structure inherits from @code{struct tree_decl_common}. It +contains a field to store the low-level RTL associated with a +@code{DECL} node. + +@item struct tree_result_decl +This structure inherits from @code{struct tree_decl_with_rtl}. It is +used to represent @code{RESULT_DECL}. + +@item struct tree_const_decl +This structure inherits from @code{struct tree_decl_with_rtl}. It is +used to represent @code{CONST_DECL}. + +@item struct tree_parm_decl +This structure inherits from @code{struct tree_decl_with_rtl}. It is +used to represent @code{PARM_DECL}. + +@item struct tree_decl_with_vis +This structure inherits from @code{struct tree_decl_with_rtl}. It +contains fields necessary to store visibility information, as well as +a section name and assembler name. + +@item struct tree_var_decl +This structure inherits from @code{struct tree_decl_with_vis}. It is +used to represent @code{VAR_DECL}. + +@item struct tree_function_decl +This structure inherits from @code{struct tree_decl_with_vis}. It is +used to represent @code{FUNCTION_DECL}. + +@end table +@node Adding new DECL node types +@subsubsection Adding new DECL node types + +Adding a new @code{DECL} tree consists of the following steps + +@table @asis + +@item Add a new tree code for the @code{DECL} node +For language specific @code{DECL} nodes, there is a @file{.def} file +in each frontend directory where the tree code should be added. +For @code{DECL} nodes that are part of the middle-end, the code should +be added to @file{tree.def}. + +@item Create a new structure type for the @code{DECL} node +These structures should inherit from one of the existing structures in +the language hierarchy by using that structure as the first member. + +@smallexample +struct tree_foo_decl +@{ + struct tree_decl_with_vis common; +@} +@end smallexample + +Would create a structure name @code{tree_foo_decl} that inherits from +@code{struct tree_decl_with_vis}. + +For language specific @code{DECL} nodes, this new structure type +should go in the appropriate @file{.h} file. +For @code{DECL} nodes that are part of the middle-end, the structure +type should go in @file{tree.h}. + +@item Add a member to the tree structure enumerator for the node +For garbage collection and dynamic checking purposes, each @code{DECL} +node structure type is required to have a unique enumerator value +specified with it. +For language specific @code{DECL} nodes, this new enumerator value +should go in the approriate @file{.def} file. +For @code{DECL} nodes that are part of the middle-end, the enumerator +values are specified in @file{treestruct.def}. + +@item Update @code{union tree_node} +In order to make your new structure type usable, it must be added to +@code{union tree_node}. +For language specific @code{DECL} nodes, a new entry should be added +to the approriate @file{.h} file of the form +@smallexample + struct tree_foo_decl GTY ((tag ("TS_VAR_DECL"))) foo_decl; +@end smallexample +For @code{DECL} nodes that are part of the middle-end, the additional +member goes directly into @code{union tree_node} in @file{tree.h}. + +@item Update dynamic checking info +In order to be able to check whether accessing a named portion of +@code{union tree_node} is legal, and whether a certain @code{DECL} node +contains one of the enumerated @code{DECL} node structures in the +hierarchy, a simple lookup table is used. +This lookup table needs to be kept up to date with the tree structure +hierarchy, or else checking and containment macros will fail +inapproriately. + +For language specific @code{DECL} nodes, their is an @code{init_ts} +function in an approriate @file{.c} file, which initializes the lookup +table. +Code setting up the table for new @code{DECL} nodes should be added +there. +For each @code{DECL} tree code and enumerator value representing a +member of the inheritance hierarchy, the table should contain 1 if +that tree code inherits (directly or indirectly) from that member. +Thus, a @code{FOO_DECL} node derived from @code{struct decl_with_rtl}, +and enumerator value @code{TS_FOO_DECL}, would be set up as follows +@smallexample +tree_contains_struct[FOO_DECL][TS_FOO_DECL] = 1; +tree_contains_struct[FOO_DECL][TS_DECL_WRTL] = 1; +tree_contains_struct[FOO_DECL][TS_DECL_COMMON] = 1; +tree_contains_struct[FOO_DECL][TS_DECL_MINIMAL] = 1; +@end smallexample + +For @code{DECL} nodes that are part of the middle-end, the setup code +goes into @file{tree.c}. + +@item Add macros to access any new fields and flags + +Each added field or flag should have a macro that is used to access +it, that performs approriate checking to ensure only the right type of +@code{DECL} nodes access the field. + +These macros generally take the following form +@smallexample +#define FOO_DECL_FIELDNAME(NODE) FOO_DECL_CHECK(NODE)->foo_decl.fieldname +@end smallexample +However, if the structure is simply a base class for further +structures, something like the following should be used +@smallexample +#define BASE_STRUCT_CHECK(T) CONTAINS_STRUCT_CHECK(T, TS_BASE_STRUCT) +#define BASE_STRUCT_FIELDNAME(NODE) \ + (BASE_STRUCT_CHECK(NODE)->base_struct.fieldname +@end smallexample + +@end table + + @c --------------------------------------------------------------------- @c Functions @c --------------------------------------------------------------------- diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c index e7c4adb5cdc..b4be0521861 100644 --- a/gcc/dwarf2out.c +++ b/gcc/dwarf2out.c @@ -4631,6 +4631,9 @@ dwarf_form_name (unsigned int form) static tree decl_ultimate_origin (tree decl) { + if (!CODE_CONTAINS_STRUCT (TREE_CODE (decl), TS_DECL_COMMON)) + return NULL_TREE; + /* output_inline_function sets DECL_ABSTRACT_ORIGIN for all the nodes in the function to point to themselves; ignore that if we're trying to output the abstract instance of this function. */ @@ -10143,7 +10146,7 @@ add_location_or_const_value_attribute (dw_die_ref die, tree decl, XXX: If you split a variable across multiple sections, this won't notice. */ - if (DECL_SECTION_NAME (decl)) + if (VAR_OR_FUNCTION_DECL_P (decl) && DECL_SECTION_NAME (decl)) { tree sectree = DECL_SECTION_NAME (decl); secname = TREE_STRING_POINTER (sectree); diff --git a/gcc/emit-rtl.c b/gcc/emit-rtl.c index 351c70ba7f9..fc34f6ecb51 100644 --- a/gcc/emit-rtl.c +++ b/gcc/emit-rtl.c @@ -954,7 +954,7 @@ set_reg_attrs_for_parm (rtx parm_rtx, rtx mem) void set_decl_rtl (tree t, rtx x) { - DECL_CHECK (t)->decl.rtl = x; + DECL_WRTL_CHECK (t)->decl_with_rtl.rtl = x; if (!x) return; diff --git a/gcc/expmed.c b/gcc/expmed.c index e54f0430cf5..a58ae0ff578 100644 --- a/gcc/expmed.c +++ b/gcc/expmed.c @@ -4939,7 +4939,7 @@ make_tree (tree type, rtx x) /* Note that we do *not* use SET_DECL_RTL here, because we do not want set_decl_rtl to go adjusting REG_ATTRS for this temporary. */ - t->decl.rtl = x; + t->decl_with_rtl.rtl = x; return t; } diff --git a/gcc/fold-const.c b/gcc/fold-const.c index 682ae00a08c..beee337487b 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -8736,7 +8736,7 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) object against zero, then we know the result. */ if ((code == EQ_EXPR || code == NE_EXPR) && TREE_CODE (arg0) == ADDR_EXPR - && DECL_P (TREE_OPERAND (arg0, 0)) + && VAR_OR_FUNCTION_DECL_P (TREE_OPERAND (arg0, 0)) && ! DECL_WEAK (TREE_OPERAND (arg0, 0)) && integer_zerop (arg1)) return constant_boolean_node (code != EQ_EXPR, type); @@ -8746,13 +8746,13 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) have access to attributes for externs), then we know the result. */ if ((code == EQ_EXPR || code == NE_EXPR) && TREE_CODE (arg0) == ADDR_EXPR - && DECL_P (TREE_OPERAND (arg0, 0)) + && VAR_OR_FUNCTION_DECL_P (TREE_OPERAND (arg0, 0)) && ! DECL_WEAK (TREE_OPERAND (arg0, 0)) && ! lookup_attribute ("alias", DECL_ATTRIBUTES (TREE_OPERAND (arg0, 0))) && ! DECL_EXTERNAL (TREE_OPERAND (arg0, 0)) && TREE_CODE (arg1) == ADDR_EXPR - && DECL_P (TREE_OPERAND (arg1, 0)) + && VAR_OR_FUNCTION_DECL_P (TREE_OPERAND (arg1, 0)) && ! DECL_WEAK (TREE_OPERAND (arg1, 0)) && ! lookup_attribute ("alias", DECL_ATTRIBUTES (TREE_OPERAND (arg1, 0))) @@ -10181,14 +10181,14 @@ fold_checksum_tree (tree expr, struct md5_ctx *ctx, htab_t ht) { void **slot; enum tree_code code; - char buf[sizeof (struct tree_decl)]; + char buf[sizeof (struct tree_decl_non_common)]; int i, len; recursive_label: gcc_assert ((sizeof (struct tree_exp) + 5 * sizeof (tree) - <= sizeof (struct tree_decl)) - && sizeof (struct tree_type) <= sizeof (struct tree_decl)); + <= sizeof (struct tree_decl_non_common)) + && sizeof (struct tree_type) <= sizeof (struct tree_decl_non_common)); if (expr == NULL) return; slot = htab_find_slot (ht, expr, INSERT); @@ -10834,7 +10834,7 @@ tree_expr_nonzero_p (tree t) return false; /* Weak declarations may link to NULL. */ - if (DECL_P (base)) + if (VAR_OR_FUNCTION_DECL_P (base)) return !DECL_WEAK (base); /* Constants are never weak. */ diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index b09cb7e3f1a..4d6a44bd7f4 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,8 @@ +2005-07-08 Daniel Berlin <dberlin@dberlin.org> + + * trans-decl.c (create_function_arglist): DECL_ARG_TYPE_AS_WRITTEN + is removed. + 2005-07-08 Jakub Jelinek <jakub@redhat.com> * primary.c (gfc_match_rvalue): Handle ENTRY the same way diff --git a/gcc/fortran/trans-decl.c b/gcc/fortran/trans-decl.c index b0d6e6b2114..ad53cbdc5a7 100644 --- a/gcc/fortran/trans-decl.c +++ b/gcc/fortran/trans-decl.c @@ -1217,7 +1217,6 @@ create_function_arglist (gfc_symbol * sym) /* Fill in arg stuff. */ DECL_CONTEXT (parm) = fndecl; DECL_ARG_TYPE (parm) = type; - DECL_ARG_TYPE_AS_WRITTEN (parm) = type; /* All implementation args are read-only. */ TREE_READONLY (parm) = 1; diff --git a/gcc/ggc-page.c b/gcc/ggc-page.c index f9c49f3a7f4..85b73adf8af 100644 --- a/gcc/ggc-page.c +++ b/gcc/ggc-page.c @@ -186,7 +186,10 @@ Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA static const size_t extra_order_size_table[] = { sizeof (struct stmt_ann_d), - sizeof (struct tree_decl), + sizeof (struct tree_decl_non_common), + sizeof (struct tree_field_decl), + sizeof (struct tree_parm_decl), + sizeof (struct tree_var_decl), sizeof (struct tree_list), TREE_EXP_SIZE (2), RTL_SIZE (2), /* MEM, PLUS, etc. */ diff --git a/gcc/gimplify.c b/gcc/gimplify.c index 8bc79087774..13cf0267fc3 100644 --- a/gcc/gimplify.c +++ b/gcc/gimplify.c @@ -860,7 +860,8 @@ gimplify_bind_expr (tree *expr_p, tree temp, tree *pre_p) /* Mark variables seen in this bind expr. */ for (t = BIND_EXPR_VARS (bind_expr); t ; t = TREE_CHAIN (t)) { - DECL_SEEN_IN_BIND_EXPR_P (t) = 1; + if (TREE_CODE (t) == VAR_DECL) + DECL_SEEN_IN_BIND_EXPR_P (t) = 1; /* Preliminarily mark non-addressed complex variables as eligible for promotion to gimple registers. We'll transform their uses @@ -3035,7 +3036,8 @@ gimplify_modify_expr_rhs (tree *expr_p, tree *from_p, tree *to_p, tree *pre_p, When optimizing, the return_slot pass marks more functions as safe after we have escape info. */ use_target = false; - else if (DECL_GIMPLE_FORMAL_TEMP_P (*to_p)) + else if (TREE_CODE (*to_p) != PARM_DECL + && DECL_GIMPLE_FORMAL_TEMP_P (*to_p)) /* Don't use the original target if it's a formal temp; we don't want to take their addresses. */ use_target = false; diff --git a/gcc/integrate.c b/gcc/integrate.c index 31ff9c76e08..eadf6606830 100644 --- a/gcc/integrate.c +++ b/gcc/integrate.c @@ -137,7 +137,8 @@ copy_decl_for_inlining (tree decl, tree from_fn, tree to_fn) DECL_ABSTRACT_ORIGIN (copy) = DECL_ORIGIN (decl); /* The new variable/label has no RTL, yet. */ - if (!TREE_STATIC (copy) && !DECL_EXTERNAL (copy)) + if (CODE_CONTAINS_STRUCT (TREE_CODE (copy), TS_DECL_WRTL) + && !TREE_STATIC (copy) && !DECL_EXTERNAL (copy)) SET_DECL_RTL (copy, NULL_RTX); /* These args would always appear unused, if not for this. */ diff --git a/gcc/java/ChangeLog b/gcc/java/ChangeLog index 2e0fecd5465..b1eed198a8f 100644 --- a/gcc/java/ChangeLog +++ b/gcc/java/ChangeLog @@ -1,3 +1,10 @@ +2005-07-08 Daniel Berlin <dberlin@dberlin.org> + + * java-tree.h (LABEL_RETURN_LABELS): Use decl_non_common. + (LABEL_PENDING_CHAIN): Ditto. + (LABEL_PC): Ditto. + (DECL_BIT_INDEX): Ditto. + 2005-07-07 Bryce McKinlay <mckinlay@redhat.com> PR java/18119 diff --git a/gcc/java/java-tree.h b/gcc/java/java-tree.h index fec7121865f..5b634357879 100644 --- a/gcc/java/java-tree.h +++ b/gcc/java/java-tree.h @@ -850,11 +850,11 @@ union lang_tree_node #define FIELD_THISN(DECL) DECL_LANG_FLAG_7 (VAR_OR_FIELD_CHECK (DECL)) /* In a LABEL_DECL, a TREE_VEC that saves the type_map at that point. */ -#define LABEL_TYPE_STATE(NODE) (DECL_INITIAL (LABEL_DECL_CHECK (NODE))) +#define LABEL_TYPE_STATE(NODE) (LABEL_DECL_CHECK (NODE)->label_decl.java_field_1) /* In the label of a subroutine, a dummy label that records the state following a merge of all the ret instructions in this subroutine. */ -#define LABEL_RETURN_LABEL(DECL) DECL_ARGUMENTS(DECL) +#define LABEL_RETURN_LABEL(DECL) (LABEL_DECL_CHECK (DECL)->label_decl.java_field_2) /* In the label of a sub-routine, records the type state at return. A local may be TYPE_UNUSED, which means that the local is not @@ -869,14 +869,14 @@ union lang_tree_node /* In the label of a sub-routine, a chain of the return location labels. */ #define LABEL_RETURN_LABELS(node) \ - (LABEL_DECL_CHECK (LABEL_RETURN_LABEL (node))->decl.result) + (LABEL_DECL_CHECK (LABEL_RETURN_LABEL (node))->label_decl.java_field_3) /* In a LABEL_DECL, the next pending label. See pending_blocks in expr.c. */ -#define LABEL_PENDING_CHAIN(NODE) (LABEL_DECL_CHECK (NODE)->decl.result) +#define LABEL_PENDING_CHAIN(NODE) (LABEL_DECL_CHECK (NODE)->label_decl.java_field_3) /* In a LABEL_DECL, the corresponding bytecode program counter. */ -#define LABEL_PC(NODE) (LABEL_DECL_CHECK (NODE)->decl.u2.i) +#define LABEL_PC(NODE) (LABEL_DECL_CHECK (NODE)->label_decl.java_field_4) /* Used during verification to mark the label has "changed". (See JVM Spec). */ #define LABEL_CHANGED(NODE) DECL_LANG_FLAG_6 (LABEL_DECL_CHECK (NODE)) @@ -969,7 +969,7 @@ union lang_tree_node that specifies if this decl is definitively assigned. The value -1 means the variable has been definitely assigned (and not definitely unassigned). The value -2 means we already reported an error. */ -#define DECL_BIT_INDEX(DECL) VAR_OR_FIELD_CHECK (DECL)->decl.pointer_alias_set +#define DECL_BIT_INDEX(DECL) VAR_OR_FIELD_CHECK (DECL)->decl_common.pointer_alias_set /* DECL_LANG_SPECIFIC for FUNCTION_DECLs. */ struct lang_decl_func GTY(()) diff --git a/gcc/langhooks-def.h b/gcc/langhooks-def.h index cd9a98e6479..a17927a2eb2 100644 --- a/gcc/langhooks-def.h +++ b/gcc/langhooks-def.h @@ -126,6 +126,7 @@ extern int lhd_gimplify_expr (tree *, tree *, tree *); #define LANG_HOOKS_BUILTIN_FUNCTION builtin_function #define LANG_HOOKS_EXPR_TO_DECL lhd_expr_to_decl #define LANG_HOOKS_TO_TARGET_CHARSET lhd_to_target_charset +#define LANG_HOOKS_INIT_TS lhd_do_nothing #define LANG_HOOKS_FUNCTION_INIT lhd_do_nothing_f #define LANG_HOOKS_FUNCTION_FINAL lhd_do_nothing_f @@ -301,6 +302,7 @@ extern tree lhd_make_node (enum tree_code); LANG_HOOKS_GIMPLIFY_EXPR, \ LANG_HOOKS_FOLD_OBJ_TYPE_REF, \ LANG_HOOKS_BUILTIN_FUNCTION, \ + LANG_HOOKS_INIT_TS, \ LANG_HOOKS_EXPR_TO_DECL, \ } diff --git a/gcc/langhooks.h b/gcc/langhooks.h index 9ec07ad71f8..cdb547c7cf3 100644 --- a/gcc/langhooks.h +++ b/gcc/langhooks.h @@ -412,6 +412,9 @@ struct lang_hooks enum built_in_class bt_class, const char *library_name, tree attrs); + /* Used to set up the tree_contains_structure array for a frontend. */ + void (*init_ts) (void); + /* Called by recompute_tree_invarant_for_addr_expr to go from EXPR to a contained expression or DECL, possibly updating *TC, *TI or *SE if in the process TREE_CONSTANT, TREE_INVARIANT or diff --git a/gcc/objc/ChangeLog b/gcc/objc/ChangeLog index 00fa28acd66..9bd62da8e4f 100644 --- a/gcc/objc/ChangeLog +++ b/gcc/objc/ChangeLog @@ -1,3 +1,17 @@ +2005-07-08 Daniel Berlin <dberlin@dberlin.org> + + * objc-act.c (objc_push_parm): DECL_ARG_TYPE_AS_WRITTEN is + removed. + * objc-act.h (KEYWORD_ARG_NAME): Use decl_non_common. + (KEYWORD_KEY_NAME): Use decl_minimal. + (METHOD_SEL_NAME): Ditto.. + (METHOD_SEL_ARGS): Use decl_non_common. + (METHOD_ADD_ARGS): Ditto. + (METHOD_ADD_ARGS_ELLIPSIS_P): Use decl_common. + (METHOD_DEFINITION): Ditto. + (METHOD_ENCODING): Ditto. + * objc-lang.c: (objc_init_ts): New function. + 2005-07-07 Ziemowit Laski <zlaski@apple.com> * objc-act.c (objc_build_struct): Pass in an actual @interface diff --git a/gcc/objc/objc-act.c b/gcc/objc/objc-act.c index 35d534368de..ee7b0287271 100644 --- a/gcc/objc/objc-act.c +++ b/gcc/objc/objc-act.c @@ -8244,7 +8244,6 @@ objc_push_parm (tree parm) else if (TREE_CODE (TREE_TYPE (parm)) == FUNCTION_TYPE) TREE_TYPE (parm) = build_pointer_type (TREE_TYPE (parm)); - DECL_ARG_TYPE_AS_WRITTEN (parm) = TREE_TYPE (parm); DECL_ARG_TYPE (parm) = lang_hooks.types.type_promotes_to (TREE_TYPE (parm)); diff --git a/gcc/objc/objc-act.h b/gcc/objc/objc-act.h index dc62862673a..d801865688b 100644 --- a/gcc/objc/objc-act.h +++ b/gcc/objc/objc-act.h @@ -44,16 +44,16 @@ enum gimplify_status objc_gimplify_expr (tree *, tree *, tree *); #define OBJC_INFO_SLOT_ELTS 2 /* KEYWORD_DECL */ -#define KEYWORD_KEY_NAME(DECL) ((DECL)->decl.name) -#define KEYWORD_ARG_NAME(DECL) ((DECL)->decl.arguments) +#define KEYWORD_KEY_NAME(DECL) ((DECL)->decl_minimal.name) +#define KEYWORD_ARG_NAME(DECL) ((DECL)->decl_non_common.arguments) /* INSTANCE_METHOD_DECL, CLASS_METHOD_DECL */ -#define METHOD_SEL_NAME(DECL) ((DECL)->decl.name) -#define METHOD_SEL_ARGS(DECL) ((DECL)->decl.arguments) -#define METHOD_ADD_ARGS(DECL) ((DECL)->decl.result) -#define METHOD_ADD_ARGS_ELLIPSIS_P(DECL) ((DECL)->decl.lang_flag_0) -#define METHOD_DEFINITION(DECL) ((DECL)->decl.initial) -#define METHOD_ENCODING(DECL) ((DECL)->decl.context) +#define METHOD_SEL_NAME(DECL) ((DECL)->decl_minimal.name) +#define METHOD_SEL_ARGS(DECL) ((DECL)->decl_non_common.arguments) +#define METHOD_ADD_ARGS(DECL) ((DECL)->decl_non_common.result) +#define METHOD_ADD_ARGS_ELLIPSIS_P(DECL) ((DECL)->decl_common.lang_flag_0) +#define METHOD_DEFINITION(DECL) ((DECL)->decl_common.initial) +#define METHOD_ENCODING(DECL) ((DECL)->decl_minimal.context) /* CLASS_INTERFACE_TYPE, CLASS_IMPLEMENTATION_TYPE, CATEGORY_INTERFACE_TYPE, CATEGORY_IMPLEMENTATION_TYPE, diff --git a/gcc/objc/objc-lang.c b/gcc/objc/objc-lang.c index 93db774065a..b94f037c547 100644 --- a/gcc/objc/objc-lang.c +++ b/gcc/objc/objc-lang.c @@ -34,6 +34,7 @@ Boston, MA 02110-1301, USA. */ #include "c-objc-common.h" enum c_language_kind c_language = clk_objc; +static void objc_init_ts (void); /* Lang hooks common to C and ObjC are declared in c-objc-common.h; consequently, there should be very few hooks below. */ @@ -48,6 +49,8 @@ enum c_language_kind c_language = clk_objc; #define LANG_HOOKS_GIMPLIFY_EXPR objc_gimplify_expr #undef LANG_HOOKS_GET_CALLEE_FNDECL #define LANG_HOOKS_GET_CALLEE_FNDECL objc_get_callee_fndecl +#undef LANG_HOOKS_INIT_TS +#define LANG_HOOKS_INIT_TS objc_init_ts /* Each front end provides its own lang hook initializer. */ const struct lang_hooks lang_hooks = LANG_HOOKS_INITIALIZER; @@ -97,6 +100,30 @@ const char * const tree_code_name[] = { /* Lang hook routines common to C and ObjC appear in c-objc-common.c; there should be very few (if any) routines below. */ +static void +objc_init_ts (void) +{ + tree_contains_struct[CLASS_METHOD_DECL][TS_DECL_NON_COMMON] = 1; + tree_contains_struct[INSTANCE_METHOD_DECL][TS_DECL_NON_COMMON] = 1; + tree_contains_struct[KEYWORD_DECL][TS_DECL_NON_COMMON] = 1; + + tree_contains_struct[CLASS_METHOD_DECL][TS_DECL_WITH_VIS] = 1; + tree_contains_struct[INSTANCE_METHOD_DECL][TS_DECL_WITH_VIS] = 1; + tree_contains_struct[KEYWORD_DECL][TS_DECL_WITH_VIS] = 1; + + tree_contains_struct[CLASS_METHOD_DECL][TS_DECL_WRTL] = 1; + tree_contains_struct[INSTANCE_METHOD_DECL][TS_DECL_WRTL] = 1; + tree_contains_struct[KEYWORD_DECL][TS_DECL_WRTL] = 1; + + tree_contains_struct[CLASS_METHOD_DECL][TS_DECL_MINIMAL] = 1; + tree_contains_struct[INSTANCE_METHOD_DECL][TS_DECL_MINIMAL] = 1; + tree_contains_struct[KEYWORD_DECL][TS_DECL_MINIMAL] = 1; + + tree_contains_struct[CLASS_METHOD_DECL][TS_DECL_COMMON] = 1; + tree_contains_struct[INSTANCE_METHOD_DECL][TS_DECL_COMMON] = 1; + tree_contains_struct[KEYWORD_DECL][TS_DECL_COMMON] = 1; +} + void finish_file (void) { diff --git a/gcc/passes.c b/gcc/passes.c index 67ffffb350d..8d1411a89e7 100644 --- a/gcc/passes.c +++ b/gcc/passes.c @@ -137,7 +137,7 @@ rest_of_decl_compilation (tree decl, /* Can't defer this, because it needs to happen before any later function definitions are processed. */ - if (DECL_REGISTER (decl) && DECL_ASSEMBLER_NAME_SET_P (decl)) + if (DECL_ASSEMBLER_NAME_SET_P (decl) && DECL_REGISTER (decl)) make_decl_rtl (decl); /* Forward declarations for nested functions are not "external", diff --git a/gcc/print-tree.c b/gcc/print-tree.c index b251933da66..9bd79f4452e 100644 --- a/gcc/print-tree.c +++ b/gcc/print-tree.c @@ -167,11 +167,13 @@ print_node (FILE *file, const char *prefix, tree node, int indent) int len; int i; expanded_location xloc; + enum tree_code code; if (node == 0) return; - - class = TREE_CODE_CLASS (TREE_CODE (node)); + + code = TREE_CODE (node); + class = TREE_CODE_CLASS (code); /* Don't get too deep in nesting. If the user wants to see deeper, it is easy to use the address of a lowest-level node @@ -319,21 +321,23 @@ print_node (FILE *file, const char *prefix, tree node, int indent) if (DECL_IGNORED_P (node)) fputs (" ignored", file); if (DECL_ABSTRACT (node)) - fputs (" abstract", file); - if (DECL_IN_SYSTEM_HEADER (node)) - fputs (" in_system_header", file); - if (DECL_COMMON (node)) - fputs (" common", file); + fputs (" abstract", file); if (DECL_EXTERNAL (node)) fputs (" external", file); - if (DECL_WEAK (node)) - fputs (" weak", file); - if (DECL_REGISTER (node) && TREE_CODE (node) != FIELD_DECL - && TREE_CODE (node) != FUNCTION_DECL - && TREE_CODE (node) != LABEL_DECL) - fputs (" regdecl", file); if (DECL_NONLOCAL (node)) fputs (" nonlocal", file); + if (CODE_CONTAINS_STRUCT (code, TS_DECL_WITH_VIS)) + { + if (DECL_WEAK (node)) + fputs (" weak", file); + if (DECL_IN_SYSTEM_HEADER (node)) + fputs (" in_system_header", file); + } + if (CODE_CONTAINS_STRUCT (code, TS_DECL_WRTL) + && TREE_CODE (node) != LABEL_DECL + && TREE_CODE (node) != FUNCTION_DECL + && DECL_REGISTER (node)) + fputs (" regdecl", file); if (TREE_CODE (node) == TYPE_DECL && TYPE_DECL_SUPPRESS_DEBUG (node)) fputs (" suppress-debug", file); @@ -357,6 +361,8 @@ print_node (FILE *file, const char *prefix, tree node, int indent) if (TREE_CODE (node) == VAR_DECL && DECL_IN_TEXT_SECTION (node)) fputs (" in-text-section", file); + if (TREE_CODE (node) == VAR_DECL && DECL_COMMON (node)) + fputs (" common", file); if (TREE_CODE (node) == VAR_DECL && DECL_THREAD_LOCAL_P (node)) { enum tls_model kind = DECL_TLS_MODEL (node); @@ -384,7 +390,7 @@ print_node (FILE *file, const char *prefix, tree node, int indent) if (DECL_VIRTUAL_P (node)) fputs (" virtual", file); - if (DECL_DEFER_OUTPUT (node)) + if (CODE_CONTAINS_STRUCT (code, TS_DECL_WITH_VIS) && DECL_DEFER_OUTPUT (node)) fputs (" defer-output", file); if (DECL_PRESERVE_P (node)) @@ -450,13 +456,20 @@ print_node (FILE *file, const char *prefix, tree node, int indent) } print_node_brief (file, "context", DECL_CONTEXT (node), indent + 4); + print_node_brief (file, "attributes", DECL_ATTRIBUTES (node), indent + 4); - print_node_brief (file, "abstract_origin", - DECL_ABSTRACT_ORIGIN (node), indent + 4); - - print_node (file, "arguments", DECL_ARGUMENTS (node), indent + 4); - print_node (file, "result", DECL_RESULT_FLD (node), indent + 4); + + if (CODE_CONTAINS_STRUCT (code, TS_DECL_WRTL)) + { + print_node_brief (file, "abstract_origin", + DECL_ABSTRACT_ORIGIN (node), indent + 4); + } + if (CODE_CONTAINS_STRUCT (code, TS_DECL_NON_COMMON)) + { + print_node (file, "arguments", DECL_ARGUMENTS (node), indent + 4); + print_node (file, "result", DECL_RESULT_FLD (node), indent + 4); + } print_node_brief (file, "initial", DECL_INITIAL (node), indent + 4); lang_hooks.print_decl (file, node, indent); @@ -470,8 +483,6 @@ print_node (FILE *file, const char *prefix, tree node, int indent) if (TREE_CODE (node) == PARM_DECL) { print_node (file, "arg-type", DECL_ARG_TYPE (node), indent + 4); - print_node (file, "arg-type-as-written", - DECL_ARG_TYPE_AS_WRITTEN (node), indent + 4); if (DECL_INCOMING_RTL (node) != 0) { diff --git a/gcc/toplev.c b/gcc/toplev.c index 294e5b7af65..8e7da03c7e0 100644 --- a/gcc/toplev.c +++ b/gcc/toplev.c @@ -704,7 +704,8 @@ wrapup_global_declarations (tree *vec, int len) /* We're not deferring this any longer. Assignment is conditional to avoid needlessly dirtying PCH pages. */ - if (DECL_DEFER_OUTPUT (decl) != 0) + if (CODE_CONTAINS_STRUCT (TREE_CODE (decl), TS_DECL_WITH_VIS) + && DECL_DEFER_OUTPUT (decl) != 0) DECL_DEFER_OUTPUT (decl) = 0; if (TREE_CODE (decl) == VAR_DECL && DECL_SIZE (decl) == 0) diff --git a/gcc/tree-browser.c b/gcc/tree-browser.c index 53b5d828293..0c3eba0b631 100644 --- a/gcc/tree-browser.c +++ b/gcc/tree-browser.c @@ -313,13 +313,6 @@ browse_tree (tree begin) TB_WF; break; - case TB_ARG_TYPE_AS_WRITTEN: - if (head && TREE_CODE (head) == PARM_DECL) - TB_SET_HEAD (DECL_ARG_TYPE_AS_WRITTEN (head)); - else - TB_WF; - break; - case TB_ARG_TYPE: if (head && TREE_CODE (head) == PARM_DECL) TB_SET_HEAD (DECL_ARG_TYPE (head)); diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c index fcaf2a60d4c..ca00892ab0d 100644 --- a/gcc/tree-inline.c +++ b/gcc/tree-inline.c @@ -209,9 +209,6 @@ remap_decl (tree decl, inline_data *id) TREE_TYPE (t) = remap_type (TREE_TYPE (t), id); if (TREE_CODE (t) == TYPE_DECL) DECL_ORIGINAL_TYPE (t) = remap_type (DECL_ORIGINAL_TYPE (t), id); - else if (TREE_CODE (t) == PARM_DECL) - DECL_ARG_TYPE_AS_WRITTEN (t) - = remap_type (DECL_ARG_TYPE_AS_WRITTEN (t), id); /* Remap sizes as necessary. */ walk_tree (&DECL_SIZE (t), copy_body_r, id, NULL); diff --git a/gcc/tree-pretty-print.c b/gcc/tree-pretty-print.c index 17de6f361fc..1d61de214f0 100644 --- a/gcc/tree-pretty-print.c +++ b/gcc/tree-pretty-print.c @@ -1578,7 +1578,7 @@ print_declaration (pretty_printer *buffer, tree t, int spc, int flags) if (TREE_CODE (t) == TYPE_DECL) pp_string (buffer, "typedef "); - if (DECL_REGISTER (t)) + if (CODE_CONTAINS_STRUCT (TREE_CODE (t), TS_DECL_WRTL) && DECL_REGISTER (t)) pp_string (buffer, "register "); if (TREE_PUBLIC (t) && DECL_EXTERNAL (t)) diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c index 91be397db2c..5655e119943 100644 --- a/gcc/tree-vrp.c +++ b/gcc/tree-vrp.c @@ -111,7 +111,7 @@ expr_computes_nonzero (tree expr) has requested not to remove NULL pointer checks. */ if (flag_delete_null_pointer_checks && TREE_CODE (expr) == ADDR_EXPR - && DECL_P (TREE_OPERAND (expr, 0)) + && VAR_OR_FUNCTION_DECL_P (TREE_OPERAND (expr, 0)) && !DECL_WEAK (TREE_OPERAND (expr, 0))) return true; diff --git a/gcc/tree.c b/gcc/tree.c index f4e052c4c6a..20cd722ec0f 100644 --- a/gcc/tree.c +++ b/gcc/tree.c @@ -133,12 +133,6 @@ static GTY ((if_marked ("ggc_marked_p"), param_is (union tree_node))) /* General tree->tree mapping structure for use in hash tables. */ -struct tree_map GTY(()) -{ - hashval_t hash; - tree from; - tree to; -}; static GTY ((if_marked ("tree_map_marked_p"), param_is (struct tree_map))) htab_t debug_expr_for_decl; @@ -146,11 +140,20 @@ static GTY ((if_marked ("tree_map_marked_p"), param_is (struct tree_map))) static GTY ((if_marked ("tree_map_marked_p"), param_is (struct tree_map))) htab_t value_expr_for_decl; +static GTY ((if_marked ("tree_int_map_marked_p"), param_is (struct tree_int_map))) + htab_t init_priority_for_decl; + +struct tree_int_map GTY(()) +{ + tree from; + unsigned short to; +}; +static unsigned int tree_int_map_hash (const void *); +static int tree_int_map_eq (const void *, const void *); +static int tree_int_map_marked_p (const void *); static void set_type_quals (tree, int); static int type_hash_eq (const void *, const void *); static hashval_t type_hash_hash (const void *); -static int tree_map_eq (const void *, const void *); -static hashval_t tree_map_hash (const void *); static hashval_t int_cst_hash_hash (const void *); static int int_cst_hash_eq (const void *, const void *); static void print_type_hash_statistics (void); @@ -158,19 +161,20 @@ static void print_debug_expr_statistics (void); static void print_value_expr_statistics (void); static tree make_vector_type (tree, int, enum machine_mode); static int type_hash_marked_p (const void *); -static int tree_map_marked_p (const void *); static unsigned int type_hash_list (tree, hashval_t); static unsigned int attribute_hash_list (tree, hashval_t); tree global_trees[TI_MAX]; tree integer_types[itk_none]; +unsigned char tree_contains_struct[256][64]; /* Init tree.c. */ void init_ttree (void) { + /* Initialize the hash table of types. */ type_hash_table = htab_create_ggc (TYPE_HASH_INITIAL_SIZE, type_hash_hash, type_hash_eq, 0); @@ -180,12 +184,62 @@ init_ttree (void) value_expr_for_decl = htab_create_ggc (512, tree_map_hash, tree_map_eq, 0); + init_priority_for_decl = htab_create_ggc (512, tree_int_map_hash, + tree_int_map_eq, 0); int_cst_hash_table = htab_create_ggc (1024, int_cst_hash_hash, int_cst_hash_eq, NULL); int_cst_node = make_node (INTEGER_CST); + tree_contains_struct[FUNCTION_DECL][TS_DECL_NON_COMMON] = 1; + tree_contains_struct[TRANSLATION_UNIT_DECL][TS_DECL_NON_COMMON] = 1; + tree_contains_struct[TYPE_DECL][TS_DECL_NON_COMMON] = 1; + + + tree_contains_struct[CONST_DECL][TS_DECL_COMMON] = 1; + tree_contains_struct[VAR_DECL][TS_DECL_COMMON] = 1; + tree_contains_struct[PARM_DECL][TS_DECL_COMMON] = 1; + tree_contains_struct[RESULT_DECL][TS_DECL_COMMON] = 1; + tree_contains_struct[FUNCTION_DECL][TS_DECL_COMMON] = 1; + tree_contains_struct[TYPE_DECL][TS_DECL_COMMON] = 1; + tree_contains_struct[TRANSLATION_UNIT_DECL][TS_DECL_COMMON] = 1; + tree_contains_struct[LABEL_DECL][TS_DECL_COMMON] = 1; + tree_contains_struct[FIELD_DECL][TS_DECL_COMMON] = 1; + + + tree_contains_struct[CONST_DECL][TS_DECL_WRTL] = 1; + tree_contains_struct[VAR_DECL][TS_DECL_WRTL] = 1; + tree_contains_struct[PARM_DECL][TS_DECL_WRTL] = 1; + tree_contains_struct[RESULT_DECL][TS_DECL_WRTL] = 1; + tree_contains_struct[FUNCTION_DECL][TS_DECL_WRTL] = 1; + tree_contains_struct[LABEL_DECL][TS_DECL_WRTL] = 1; + + tree_contains_struct[CONST_DECL][TS_DECL_MINIMAL] = 1; + tree_contains_struct[VAR_DECL][TS_DECL_MINIMAL] = 1; + tree_contains_struct[PARM_DECL][TS_DECL_MINIMAL] = 1; + tree_contains_struct[RESULT_DECL][TS_DECL_MINIMAL] = 1; + tree_contains_struct[FUNCTION_DECL][TS_DECL_MINIMAL] = 1; + tree_contains_struct[TYPE_DECL][TS_DECL_MINIMAL] = 1; + tree_contains_struct[TRANSLATION_UNIT_DECL][TS_DECL_MINIMAL] = 1; + tree_contains_struct[LABEL_DECL][TS_DECL_MINIMAL] = 1; + tree_contains_struct[FIELD_DECL][TS_DECL_MINIMAL] = 1; + + tree_contains_struct[VAR_DECL][TS_DECL_WITH_VIS] = 1; + tree_contains_struct[FUNCTION_DECL][TS_DECL_WITH_VIS] = 1; + tree_contains_struct[TYPE_DECL][TS_DECL_WITH_VIS] = 1; + tree_contains_struct[TRANSLATION_UNIT_DECL][TS_DECL_WITH_VIS] = 1; + + tree_contains_struct[VAR_DECL][TS_VAR_DECL] = 1; + tree_contains_struct[FIELD_DECL][TS_FIELD_DECL] = 1; + tree_contains_struct[PARM_DECL][TS_PARM_DECL] = 1; + tree_contains_struct[LABEL_DECL][TS_LABEL_DECL] = 1; + tree_contains_struct[RESULT_DECL][TS_RESULT_DECL] = 1; + tree_contains_struct[CONST_DECL][TS_CONST_DECL] = 1; + tree_contains_struct[TYPE_DECL][TS_TYPE_DECL] = 1; + tree_contains_struct[FUNCTION_DECL][TS_FUNCTION_DECL] = 1; + + lang_hooks.init_ts (); } @@ -197,7 +251,7 @@ decl_assembler_name (tree decl) { if (!DECL_ASSEMBLER_NAME_SET_P (decl)) lang_hooks.set_decl_assembler_name (decl); - return DECL_CHECK (decl)->decl.assembler_name; + return DECL_WITH_VIS_CHECK (decl)->decl_with_vis.assembler_name; } /* Compute the number of bytes occupied by a tree with code CODE. @@ -209,7 +263,29 @@ tree_code_size (enum tree_code code) switch (TREE_CODE_CLASS (code)) { case tcc_declaration: /* A decl node */ - return sizeof (struct tree_decl); + { + switch (code) + { + case FIELD_DECL: + return sizeof (struct tree_field_decl); + case PARM_DECL: + return sizeof (struct tree_parm_decl); + case VAR_DECL: + return sizeof (struct tree_var_decl); + case LABEL_DECL: + return sizeof (struct tree_label_decl); + case RESULT_DECL: + return sizeof (struct tree_result_decl); + case CONST_DECL: + return sizeof (struct tree_const_decl); + case TYPE_DECL: + return sizeof (struct tree_type_decl); + case FUNCTION_DECL: + return sizeof (struct tree_function_decl); + default: + return sizeof (struct tree_decl_non_common); + } + } case tcc_type: /* a type node */ return sizeof (struct tree_type); @@ -395,12 +471,13 @@ make_node_stat (enum tree_code code MEM_STAT_DECL) if (code != FUNCTION_DECL) DECL_ALIGN (t) = 1; DECL_USER_ALIGN (t) = 0; - DECL_IN_SYSTEM_HEADER (t) = in_system_header; + if (CODE_CONTAINS_STRUCT (code, TS_DECL_WITH_VIS)) + DECL_IN_SYSTEM_HEADER (t) = in_system_header; + /* We have not yet computed the alias set for this declaration. */ + DECL_POINTER_ALIAS_SET (t) = -1; DECL_SOURCE_LOCATION (t) = input_location; DECL_UID (t) = next_decl_uid++; - /* We have not yet computed the alias set for this declaration. */ - DECL_POINTER_ALIAS_SET (t) = -1; break; case tcc_type: @@ -480,6 +557,11 @@ copy_node_stat (tree node MEM_STAT_DECL) SET_DECL_VALUE_EXPR (t, DECL_VALUE_EXPR (node)); DECL_HAS_VALUE_EXPR_P (t) = 1; } + if (TREE_CODE (node) == VAR_DECL && DECL_HAS_INIT_PRIORITY_P (node)) + { + SET_DECL_INIT_PRIORITY (t, DECL_INIT_PRIORITY (node)); + DECL_HAS_INIT_PRIORITY_P (t) = 1; + } } else if (TREE_CODE_CLASS (code) == tcc_type) @@ -1814,9 +1896,31 @@ tree_node_structure (tree t) enum tree_code code = TREE_CODE (t); switch (TREE_CODE_CLASS (code)) - { + { case tcc_declaration: - return TS_DECL; + { + switch (code) + { + case FIELD_DECL: + return TS_FIELD_DECL; + case PARM_DECL: + return TS_PARM_DECL; + case VAR_DECL: + return TS_VAR_DECL; + case LABEL_DECL: + return TS_LABEL_DECL; + case RESULT_DECL: + return TS_RESULT_DECL; + case CONST_DECL: + return TS_CONST_DECL; + case TYPE_DECL: + return TS_TYPE_DECL; + case FUNCTION_DECL: + return TS_FUNCTION_DECL; + default: + return TS_DECL_NON_COMMON; + } + } case tcc_type: return TS_TYPE; case tcc_reference: @@ -2877,10 +2981,13 @@ build_decl_stat (enum tree_code code, tree name, tree type MEM_STAT_DECL) else if (code == FUNCTION_DECL) DECL_MODE (t) = FUNCTION_MODE; - /* Set default visibility to whatever the user supplied with - visibility_specified depending on #pragma GCC visibility. */ - DECL_VISIBILITY (t) = default_visibility; - DECL_VISIBILITY_SPECIFIED (t) = visibility_options.inpragma; + if (CODE_CONTAINS_STRUCT (code, TS_DECL_WITH_VIS)) + { + /* Set default visibility to whatever the user supplied with + visibility_specified depending on #pragma GCC visibility. */ + DECL_VISIBILITY (t) = default_visibility; + DECL_VISIBILITY_SPECIFIED (t) = visibility_options.inpragma; + } return t; } @@ -3513,7 +3620,7 @@ build_variant_type_copy (tree type) /* Return true if the from tree in both tree maps are equal. */ -static int +int tree_map_eq (const void *va, const void *vb) { const struct tree_map *a = va, *b = vb; @@ -3522,7 +3629,7 @@ tree_map_eq (const void *va, const void *vb) /* Hash a from tree in a tree_map. */ -static hashval_t +unsigned int tree_map_hash (const void *item) { return (((const struct tree_map *) item)->hash); @@ -3532,7 +3639,7 @@ tree_map_hash (const void *item) purposes. We simply return true if the from tree is marked, so that this structure goes away when the from tree goes away. */ -static int +int tree_map_marked_p (const void *p) { tree from = ((struct tree_map *) p)->from; @@ -3540,6 +3647,65 @@ tree_map_marked_p (const void *p) return ggc_marked_p (from); } +/* Return true if the trees in the tree_int_map *'s VA and VB are equal. */ + +static int +tree_int_map_eq (const void *va, const void *vb) +{ + const struct tree_int_map *a = va, *b = vb; + return (a->from == b->from); +} + +/* Hash a from tree in the tree_int_map * ITEM. */ + +static unsigned int +tree_int_map_hash (const void *item) +{ + return htab_hash_pointer (((const struct tree_int_map *)item)->from); +} + +/* Return true if this tree int map structure is marked for garbage collection + purposes. We simply return true if the from tree_int_map *P's from tree is marked, so that this + structure goes away when the from tree goes away. */ + +static int +tree_int_map_marked_p (const void *p) +{ + tree from = ((struct tree_int_map *) p)->from; + + return ggc_marked_p (from); +} +/* Lookup an init priority for FROM, and return it if we find one. */ + +unsigned short +decl_init_priority_lookup (tree from) +{ + struct tree_int_map *h, in; + in.from = from; + + h = htab_find_with_hash (init_priority_for_decl, + &in, htab_hash_pointer (from)); + if (h) + return h->to; + return 0; +} + +/* Insert a mapping FROM->TO in the init priority hashtable. */ + +void +decl_init_priority_insert (tree from, unsigned short to) +{ + struct tree_int_map *h; + void **loc; + + h = ggc_alloc (sizeof (struct tree_int_map)); + h->from = from; + h->to = to; + loc = htab_find_slot_with_hash (init_priority_for_decl, h, + htab_hash_pointer (from), INSERT); + *(struct tree_int_map **) loc = h; +} + /* Print out the statistics for the DECL_DEBUG_EXPR hash table. */ static void @@ -5664,6 +5830,31 @@ tree_class_check_failed (const tree node, const enum tree_code_class cl, TREE_CODE_CLASS_STRING (TREE_CODE_CLASS (TREE_CODE (node))), tree_code_name[TREE_CODE (node)], function, trim_filename (file), line); } +#undef DEFTREESTRUCT +#define DEFTREESTRUCT(VAL, NAME) NAME, + +static const char *ts_enum_names[] = { +#include "treestruct.def" +}; +#undef DEFTREESTRUCT + +#define TS_ENUM_NAME(EN) (ts_enum_names[(EN)]) + +/* Similar to tree_class_check_failed, except that we check for + whether CODE contains the tree structure identified by EN. */ + +void +tree_contains_struct_check_failed (const tree node, + const enum tree_node_structure_enum en, + const char *file, int line, + const char *function) +{ + internal_error + ("tree check: expected tree that contains %qs structure, have %qs in %s, at %s:%d", + TS_ENUM_NAME(en), + tree_code_name[TREE_CODE (node)], function, trim_filename (file), line); +} + /* Similar to above, except that the check is for the bounds of a TREE_VEC's (dynamically sized) vector. */ diff --git a/gcc/tree.h b/gcc/tree.h index 1d5567cfc79..eb9ebdcd05d 100644 --- a/gcc/tree.h +++ b/gcc/tree.h @@ -40,6 +40,9 @@ enum tree_code { #undef DEFTREECODE +extern unsigned char tree_contains_struct[256][64]; +#define CODE_CONTAINS_STRUCT(CODE, STRUCT) (tree_contains_struct[(CODE)][(STRUCT)]) + /* Number of language-independent tree codes. */ #define NUM_TREE_CODES ((int) LAST_AND_UNUSED_TREE_CODE) @@ -97,8 +100,14 @@ extern const enum tree_code_class tree_code_type[]; #define DECL_P(CODE)\ (TREE_CODE_CLASS (TREE_CODE (CODE)) == tcc_declaration) +/* Nonzero if DECL represents a VAR_DECL or FUNCTION_DECL. */ + +#define VAR_OR_FUNCTION_DECL_P(DECL)\ + (TREE_CODE (DECL) == VAR_DECL || TREE_CODE (DECL) == FUNCTION_DECL) + /* Nonzero if CODE represents a INDIRECT_REF. Keep these checks in ascending code order. */ + #define INDIRECT_REF_P(CODE)\ (TREE_CODE (CODE) == INDIRECT_REF \ || TREE_CODE (CODE) == ALIGN_INDIRECT_REF \ @@ -433,6 +442,13 @@ struct tree_common GTY(()) TREE_NO_WARNING in ... any expr or decl node */ +#undef DEFTREESTRUCT +#define DEFTREESTRUCT(ENUM, NAME) ENUM, +enum tree_node_structure_enum { +#include "treestruct.def" + LAST_TS_ENUM +}; +#undef DEFTREESTRUCT /* Define accessors for the fields that all tree nodes have (though some fields are not used for all kinds of nodes). */ @@ -536,6 +552,13 @@ struct tree_common GTY(()) (CODE1), (CODE2), (CODE3), (CODE4), (CODE5), 0);\ __t; }) +#define CONTAINS_STRUCT_CHECK(T, STRUCT) __extension__ \ +({ const tree __t = (T); \ + if (tree_contains_struct[TREE_CODE(__t)][(STRUCT)] != 1) \ + tree_contains_struct_check_failed (__t, (STRUCT), __FILE__, __LINE__, \ + __FUNCTION__); \ + __t; }) + #define TREE_CLASS_CHECK(T, CLASS) __extension__ \ ({ const tree __t = (T); \ if (TREE_CODE_CLASS (TREE_CODE(__t)) != (CLASS)) \ @@ -612,6 +635,11 @@ struct tree_common GTY(()) __FILE__, __LINE__, __FUNCTION__); \ &__t->exp.operands[__i]; })) +extern void tree_contains_struct_check_failed (const tree, + const enum tree_node_structure_enum, + const char *, int, const char *) + ATTRIBUTE_NORETURN; + extern void tree_check_failed (const tree, const char *, int, const char *, ...) ATTRIBUTE_NORETURN; extern void tree_not_check_failed (const tree, const char *, int, const char *, @@ -631,6 +659,7 @@ extern void tree_operand_check_failed (int, enum tree_code, #else /* not ENABLE_TREE_CHECKING, or not gcc */ +#define CONTAINS_STRUCT_CHECK(T, ENUM) (T) #define TREE_CHECK(T, CODE) (T) #define TREE_NOT_CHECK(T, CODE) (T) #define TREE_CHECK2(T, CODE1, CODE2) (T) @@ -657,7 +686,11 @@ extern void tree_operand_check_failed (int, enum tree_code, #include "tree-check.h" #define TYPE_CHECK(T) TREE_CLASS_CHECK (T, tcc_type) -#define DECL_CHECK(T) TREE_CLASS_CHECK (T, tcc_declaration) +#define DECL_MINIMAL_CHECK(T) CONTAINS_STRUCT_CHECK (T, TS_DECL_MINIMAL) +#define DECL_COMMON_CHECK(T) CONTAINS_STRUCT_CHECK (T, TS_DECL_COMMON) +#define DECL_WRTL_CHECK(T) CONTAINS_STRUCT_CHECK (T, TS_DECL_WRTL) +#define DECL_WITH_VIS_CHECK(T) CONTAINS_STRUCT_CHECK (T, TS_DECL_WITH_VIS) +#define DECL_NON_COMMON_CHECK(T) CONTAINS_STRUCT_CHECK (T, TS_DECL_NON_COMMON) #define CST_CHECK(T) TREE_CLASS_CHECK (T, tcc_constant) #define STMT_CHECK(T) TREE_CLASS_CHECK (T, tcc_statement) #define FUNC_OR_METHOD_CHECK(T) TREE_CHECK2 (T, FUNCTION_TYPE, METHOD_TYPE) @@ -946,7 +979,7 @@ extern void tree_operand_check_failed (int, enum tree_code, #define TYPE_SIZES_GIMPLIFIED(NODE) (TYPE_CHECK (NODE)->common.constant_flag) /* In a decl (most significantly a FIELD_DECL), means an unsigned field. */ -#define DECL_UNSIGNED(NODE) (DECL_CHECK (NODE)->common.unsigned_flag) +#define DECL_UNSIGNED(NODE) (DECL_COMMON_CHECK (NODE)->common.unsigned_flag) /* In a BIT_FIELD_REF, means the bitfield is to be interpreted as unsigned. */ #define BIT_FIELD_REF_UNSIGNED(NODE) \ @@ -986,7 +1019,7 @@ extern void tree_operand_check_failed (int, enum tree_code, /* In a RESULT_DECL or PARM_DECL, means that it is passed by invisible reference (and the TREE_TYPE is a pointer to the true type). */ -#define DECL_BY_REFERENCE(NODE) (DECL_CHECK (NODE)->common.private_flag) +#define DECL_BY_REFERENCE(NODE) (DECL_COMMON_CHECK (NODE)->common.private_flag) /* In a CALL_EXPR, means that the call is the jump from a thunk to the thunked-to function. */ @@ -1884,43 +1917,44 @@ struct tree_binfo GTY (()) || TREE_CODE (SSA_NAME_VAR (DECL)) == PARM_DECL \ || TREE_CODE (SSA_NAME_VAR (DECL)) == RESULT_DECL))) -/* This is the name of the object as written by the user. - It is an IDENTIFIER_NODE. */ -#define DECL_NAME(NODE) (DECL_CHECK (NODE)->decl.name) -/* The name of the object as the assembler will see it (but before any - translations made by ASM_OUTPUT_LABELREF). Often this is the same - as DECL_NAME. It is an IDENTIFIER_NODE. */ -#define DECL_ASSEMBLER_NAME(NODE) decl_assembler_name (NODE) -/* Returns nonzero if the DECL_ASSEMBLER_NAME for NODE has been set. If zero, - the NODE might still have a DECL_ASSEMBLER_NAME -- it just hasn't been set - yet. */ -#define DECL_ASSEMBLER_NAME_SET_P(NODE) \ - (DECL_CHECK (NODE)->decl.assembler_name != NULL_TREE) -/* Set the DECL_ASSEMBLER_NAME for NODE to NAME. */ -#define SET_DECL_ASSEMBLER_NAME(NODE, NAME) \ - (DECL_CHECK (NODE)->decl.assembler_name = (NAME)) +/* Enumerate visibility settings. */ +#ifndef SYMBOL_VISIBILITY_DEFINED +#define SYMBOL_VISIBILITY_DEFINED +enum symbol_visibility +{ + VISIBILITY_DEFAULT, + VISIBILITY_INTERNAL, + VISIBILITY_HIDDEN, + VISIBILITY_PROTECTED +}; +#endif -/* Copy the DECL_ASSEMBLER_NAME from DECL1 to DECL2. Note that if DECL1's - DECL_ASSEMBLER_NAME has not yet been set, using this macro will not cause - the DECL_ASSEMBLER_NAME of either DECL to be set. In other words, the - semantics of using this macro, are different than saying: +struct function; - SET_DECL_ASSEMBLER_NAME(DECL2, DECL_ASSEMBLER_NAME (DECL1)) - which will try to set the DECL_ASSEMBLER_NAME for DECL1. */ +/* This is the name of the object as written by the user. + It is an IDENTIFIER_NODE. */ +#define DECL_NAME(NODE) (DECL_MINIMAL_CHECK (NODE)->decl_minimal.name) -#define COPY_DECL_ASSEMBLER_NAME(DECL1, DECL2) \ - (DECL_ASSEMBLER_NAME_SET_P (DECL1) \ - ? (void) SET_DECL_ASSEMBLER_NAME (DECL2, \ - DECL_ASSEMBLER_NAME (DECL1)) \ - : (void) 0) +/* Every ..._DECL node gets a unique number. */ +#define DECL_UID(NODE) (DECL_MINIMAL_CHECK (NODE)->decl_minimal.uid) -/* Records the section name in a section attribute. Used to pass - the name from decl_attributes to make_function_rtl and make_decl_rtl. */ -#define DECL_SECTION_NAME(NODE) (DECL_CHECK (NODE)->decl.section_name) +/* These two fields describe where in the source code the declaration + was. If the declaration appears in several places (as for a C + function that is declared first and then defined later), this + information should refer to the definition. */ +#define DECL_SOURCE_LOCATION(NODE) (DECL_MINIMAL_CHECK (NODE)->decl_minimal.locus) +#define DECL_SOURCE_FILE(NODE) LOCATION_FILE (DECL_SOURCE_LOCATION (NODE)) +#define DECL_SOURCE_LINE(NODE) LOCATION_LINE (DECL_SOURCE_LOCATION (NODE)) +#ifdef USE_MAPPED_LOCATION +#define DECL_IS_BUILTIN(DECL) \ + (DECL_SOURCE_LOCATION (DECL) <= BUILTINS_LOCATION) +#else +#define DECL_IS_BUILTIN(DECL) (DECL_SOURCE_LINE(DECL) == 0) +#endif /* For FIELD_DECLs, this is the RECORD_TYPE, UNION_TYPE, or QUAL_UNION_TYPE node that the field is a member of. For VAR_DECL, @@ -1929,172 +1963,81 @@ struct tree_binfo GTY (()) the RECORD_TYPE or UNION_TYPE for the containing type, or NULL_TREE or a TRANSLATION_UNIT_DECL if the given decl has "file scope". */ -#define DECL_CONTEXT(NODE) (DECL_CHECK (NODE)->decl.context) -#define DECL_FIELD_CONTEXT(NODE) (FIELD_DECL_CHECK (NODE)->decl.context) +#define DECL_CONTEXT(NODE) (DECL_MINIMAL_CHECK (NODE)->decl_minimal.context) +#define DECL_FIELD_CONTEXT(NODE) (FIELD_DECL_CHECK (NODE)->decl_minimal.context) +struct tree_decl_minimal GTY(()) +{ + struct tree_common common; + location_t locus; + unsigned int uid; + tree name; + tree context; +}; + +/* For any sort of a ..._DECL node, this points to the original (abstract) + decl node which this decl is an instance of, or else it is NULL indicating + that this decl is not an instance of some other decl. For example, + in a nested declaration of an inline function, this points back to the + definition. */ +#define DECL_ABSTRACT_ORIGIN(NODE) (DECL_COMMON_CHECK (NODE)->decl_common.abstract_origin) + +/* Like DECL_ABSTRACT_ORIGIN, but returns NODE if there's no abstract + origin. This is useful when setting the DECL_ABSTRACT_ORIGIN. */ +#define DECL_ORIGIN(NODE) \ + (DECL_ABSTRACT_ORIGIN (NODE) ? DECL_ABSTRACT_ORIGIN (NODE) : (NODE)) + +/* Nonzero for any sort of ..._DECL node means this decl node represents an + inline instance of some original (abstract) decl from an inline function; + suppress any warnings about shadowing some other variable. FUNCTION_DECL + nodes can also have their abstract origin set to themselves. */ +#define DECL_FROM_INLINE(NODE) (DECL_ABSTRACT_ORIGIN (NODE) != NULL_TREE \ + && DECL_ABSTRACT_ORIGIN (NODE) != (NODE)) + /* In a DECL this is the field where attributes are stored. */ -#define DECL_ATTRIBUTES(NODE) (DECL_CHECK (NODE)->decl.attributes) -/* In a FIELD_DECL, this is the field position, counting in bytes, of the - byte containing the bit closest to the beginning of the structure. */ -#define DECL_FIELD_OFFSET(NODE) (FIELD_DECL_CHECK (NODE)->decl.arguments) -/* In a FIELD_DECL, this is the offset, in bits, of the first bit of the - field from DECL_FIELD_OFFSET. */ -#define DECL_FIELD_BIT_OFFSET(NODE) (FIELD_DECL_CHECK (NODE)->decl.u2.t) -/* In a FIELD_DECL, this indicates whether the field was a bit-field and - if so, the type that was originally specified for it. - TREE_TYPE may have been modified (in finish_struct). */ -#define DECL_BIT_FIELD_TYPE(NODE) (FIELD_DECL_CHECK (NODE)->decl.result) -/* In FUNCTION_DECL, a chain of ..._DECL nodes. - VAR_DECL and PARM_DECL reserve the arguments slot for language-specific - uses. */ -#define DECL_ARGUMENTS(NODE) (DECL_CHECK (NODE)->decl.arguments) -/* This field is used to reference anything in decl.result and is meant only - for use by the garbage collector. */ -#define DECL_RESULT_FLD(NODE) (DECL_CHECK (NODE)->decl.result) -/* In FUNCTION_DECL, holds the decl for the return value. */ -#define DECL_RESULT(NODE) (FUNCTION_DECL_CHECK (NODE)->decl.result) -/* For a TYPE_DECL, holds the "original" type. (TREE_TYPE has the copy.) */ -#define DECL_ORIGINAL_TYPE(NODE) (TYPE_DECL_CHECK (NODE)->decl.result) -/* In PARM_DECL, holds the type as written (perhaps a function or array). */ -#define DECL_ARG_TYPE_AS_WRITTEN(NODE) (PARM_DECL_CHECK (NODE)->decl.result) +#define DECL_ATTRIBUTES(NODE) (DECL_COMMON_CHECK (NODE)->decl_common.attributes) + /* For a FUNCTION_DECL, holds the tree of BINDINGs. For a TRANSLATION_UNIT_DECL, holds the namespace's BLOCK. For a VAR_DECL, holds the initial value. For a PARM_DECL, not used--default values for parameters are encoded in the type of the function, not in the PARM_DECL slot. + For a FIELD_DECL, this is used for enumeration values and the C + frontend uses it for temporarily storing bitwidth of bitfields. ??? Need to figure out some way to check this isn't a PARM_DECL. */ -#define DECL_INITIAL(NODE) (DECL_CHECK (NODE)->decl.initial) -/* For a PARM_DECL, records the data type used to pass the argument, - which may be different from the type seen in the program. */ -#define DECL_ARG_TYPE(NODE) (PARM_DECL_CHECK (NODE)->decl.initial) -/* For a FIELD_DECL in a QUAL_UNION_TYPE, records the expression, which - if nonzero, indicates that the field occupies the type. */ -#define DECL_QUALIFIER(NODE) (FIELD_DECL_CHECK (NODE)->decl.initial) -/* These two fields describe where in the source code the declaration - was. If the declaration appears in several places (as for a C - function that is declared first and then defined later), this - information should refer to the definition. */ -#define DECL_SOURCE_LOCATION(NODE) (DECL_CHECK (NODE)->decl.locus) -#define DECL_SOURCE_FILE(NODE) LOCATION_FILE (DECL_SOURCE_LOCATION (NODE)) -#define DECL_SOURCE_LINE(NODE) LOCATION_LINE (DECL_SOURCE_LOCATION (NODE)) -#ifdef USE_MAPPED_LOCATION -#define DECL_IS_BUILTIN(DECL) \ - (DECL_SOURCE_LOCATION (DECL) <= BUILTINS_LOCATION) -#else -#define DECL_IS_BUILTIN(DECL) (DECL_SOURCE_LINE(DECL) == 0) -#endif +#define DECL_INITIAL(NODE) (DECL_COMMON_CHECK (NODE)->decl_common.initial) + /* Holds the size of the datum, in bits, as a tree expression. Need not be constant. */ -#define DECL_SIZE(NODE) (DECL_CHECK (NODE)->decl.size) +#define DECL_SIZE(NODE) (DECL_COMMON_CHECK (NODE)->decl_common.size) /* Likewise for the size in bytes. */ -#define DECL_SIZE_UNIT(NODE) (DECL_CHECK (NODE)->decl.size_unit) +#define DECL_SIZE_UNIT(NODE) (DECL_COMMON_CHECK (NODE)->decl_common.size_unit) /* Holds the alignment required for the datum, in bits. */ -#define DECL_ALIGN(NODE) (DECL_CHECK (NODE)->decl.u1.a.align) +#define DECL_ALIGN(NODE) (DECL_COMMON_CHECK (NODE)->decl_common.u1.a.align) /* The alignment of NODE, in bytes. */ #define DECL_ALIGN_UNIT(NODE) (DECL_ALIGN (NODE) / BITS_PER_UNIT) /* For FIELD_DECLs, off_align holds the number of low-order bits of DECL_FIELD_OFFSET which are known to be always zero. DECL_OFFSET_ALIGN thus returns the alignment that DECL_FIELD_OFFSET has. */ -#define DECL_OFFSET_ALIGN(NODE) \ - (((unsigned HOST_WIDE_INT)1) << FIELD_DECL_CHECK (NODE)->decl.u1.a.off_align) -/* Specify that DECL_ALIGN(NODE) is a multiple of X. */ -#define SET_DECL_OFFSET_ALIGN(NODE, X) \ - (FIELD_DECL_CHECK (NODE)->decl.u1.a.off_align = exact_log2 ((X) & -(X))) -/* 1 if the alignment for this type was requested by "aligned" attribute, - 0 if it is the default for this type. */ -#define DECL_USER_ALIGN(NODE) (DECL_CHECK (NODE)->decl.user_align) +#define DECL_USER_ALIGN(NODE) (DECL_COMMON_CHECK (NODE)->decl_common.user_align) /* Holds the machine mode corresponding to the declaration of a variable or field. Always equal to TYPE_MODE (TREE_TYPE (decl)) except for a FIELD_DECL. */ -#define DECL_MODE(NODE) (DECL_CHECK (NODE)->decl.mode) -/* Holds the RTL expression for the value of a variable or function. - This value can be evaluated lazily for functions, variables with - static storage duration, and labels. */ -#define DECL_RTL(NODE) \ - (DECL_CHECK (NODE)->decl.rtl \ - ? (NODE)->decl.rtl \ - : (make_decl_rtl (NODE), (NODE)->decl.rtl)) -/* Set the DECL_RTL for NODE to RTL. */ -#define SET_DECL_RTL(NODE, RTL) set_decl_rtl (NODE, RTL) -/* Returns nonzero if the DECL_RTL for NODE has already been set. */ -#define DECL_RTL_SET_P(NODE) (DECL_CHECK (NODE)->decl.rtl != NULL) -/* Copy the RTL from NODE1 to NODE2. If the RTL was not set for - NODE1, it will not be set for NODE2; this is a lazy copy. */ -#define COPY_DECL_RTL(NODE1, NODE2) \ - (DECL_CHECK (NODE2)->decl.rtl = DECL_CHECK (NODE1)->decl.rtl) -/* The DECL_RTL for NODE, if it is set, or NULL, if it is not set. */ -#define DECL_RTL_IF_SET(NODE) (DECL_RTL_SET_P (NODE) ? DECL_RTL (NODE) : NULL) - -/* For PARM_DECL, holds an RTL for the stack slot or register - where the data was actually passed. */ -#define DECL_INCOMING_RTL(NODE) (PARM_DECL_CHECK (NODE)->decl.u2.r) - -/* For FUNCTION_DECL, this holds a pointer to a structure ("struct function") - that describes the status of this function. */ -#define DECL_STRUCT_FUNCTION(NODE) (FUNCTION_DECL_CHECK (NODE)->decl.u2.f) +#define DECL_MODE(NODE) (DECL_COMMON_CHECK (NODE)->decl_common.mode) /* For FUNCTION_DECL, if it is built-in, this identifies which built-in operation it is. Note, however, that this field is overloaded, with DECL_BUILT_IN_CLASS as the discriminant, so the latter must always be checked before any access to the former. */ -#define DECL_FUNCTION_CODE(NODE) (FUNCTION_DECL_CHECK (NODE)->decl.u1.f) - -/* The DECL_VINDEX is used for FUNCTION_DECLS in two different ways. - Before the struct containing the FUNCTION_DECL is laid out, - DECL_VINDEX may point to a FUNCTION_DECL in a base class which - is the FUNCTION_DECL which this FUNCTION_DECL will replace as a virtual - function. When the class is laid out, this pointer is changed - to an INTEGER_CST node which is suitable for use as an index - into the virtual function table. */ -#define DECL_VINDEX(NODE) (DECL_CHECK (NODE)->decl.vindex) - -/* For FIELD_DECLS, DECL_FCONTEXT is the *first* baseclass in - which this FIELD_DECL is defined. This information is needed when - writing debugging information about vfield and vbase decls for C++. */ -#define DECL_FCONTEXT(NODE) (FIELD_DECL_CHECK (NODE)->decl.vindex) - -extern tree decl_debug_expr_lookup (tree); -extern void decl_debug_expr_insert (tree, tree); - -/* For VAR_DECL, this is set to either an expression that it was split - from (if DECL_DEBUG_EXPR_IS_FROM is true), otherwise a tree_list of - subexpressions that it was split into. */ -#define DECL_DEBUG_EXPR(NODE) \ - (decl_debug_expr_lookup (VAR_DECL_CHECK (NODE))) - -#define SET_DECL_DEBUG_EXPR(NODE, VAL) \ - (decl_debug_expr_insert (VAR_DECL_CHECK (NODE), (VAL))) - +#define DECL_FUNCTION_CODE(NODE) (FUNCTION_DECL_CHECK (NODE)->decl_common.u1.f) #define DECL_DEBUG_EXPR_IS_FROM(NODE) \ - (DECL_CHECK (NODE)->decl.debug_expr_is_from) - -/* Every ..._DECL node gets a unique number. */ -#define DECL_UID(NODE) (DECL_CHECK (NODE)->decl.uid) - -/* For any sort of a ..._DECL node, this points to the original (abstract) - decl node which this decl is an instance of, or else it is NULL indicating - that this decl is not an instance of some other decl. For example, - in a nested declaration of an inline function, this points back to the - definition. */ -#define DECL_ABSTRACT_ORIGIN(NODE) (DECL_CHECK (NODE)->decl.abstract_origin) - -/* Like DECL_ABSTRACT_ORIGIN, but returns NODE if there's no abstract - origin. This is useful when setting the DECL_ABSTRACT_ORIGIN. */ -#define DECL_ORIGIN(NODE) \ - (DECL_ABSTRACT_ORIGIN (NODE) ? DECL_ABSTRACT_ORIGIN (NODE) : (NODE)) - -/* Nonzero for any sort of ..._DECL node means this decl node represents an - inline instance of some original (abstract) decl from an inline function; - suppress any warnings about shadowing some other variable. FUNCTION_DECL - nodes can also have their abstract origin set to themselves. */ -#define DECL_FROM_INLINE(NODE) (DECL_ABSTRACT_ORIGIN (NODE) != NULL_TREE \ - && DECL_ABSTRACT_ORIGIN (NODE) != (NODE)) + (DECL_COMMON_CHECK (NODE)->decl_common.debug_expr_is_from) /* Nonzero for a given ..._DECL node means that the name of this node should be ignored for symbolic debug purposes. */ -#define DECL_IGNORED_P(NODE) (DECL_CHECK (NODE)->decl.ignored_flag) +#define DECL_IGNORED_P(NODE) (DECL_COMMON_CHECK (NODE)->decl_common.ignored_flag) /* Nonzero for a given ..._DECL node means that this node represents an "abstract instance" of the given declaration (e.g. in the original @@ -2102,25 +2045,14 @@ extern void decl_debug_expr_insert (tree, tree); information, we mustn't try to generate any address information for nodes marked as "abstract instances" because we don't actually generate any code or allocate any data space for such instances. */ -#define DECL_ABSTRACT(NODE) (DECL_CHECK (NODE)->decl.abstract_flag) - -/* Nonzero for a given ..._DECL node means that no warnings should be - generated just because this node is unused. */ -#define DECL_IN_SYSTEM_HEADER(NODE) \ - (DECL_CHECK (NODE)->decl.in_system_header_flag) - -/* Nonzero for a given ..._DECL node means that this node should be - put in .common, if possible. If a DECL_INITIAL is given, and it - is not error_mark_node, then the decl cannot be put in .common. */ -#define DECL_COMMON(NODE) (DECL_CHECK (NODE)->decl.common_flag) +#define DECL_ABSTRACT(NODE) (DECL_COMMON_CHECK (NODE)->decl_common.abstract_flag) /* Language-specific decl information. */ -#define DECL_LANG_SPECIFIC(NODE) (DECL_CHECK (NODE)->decl.lang_specific) +#define DECL_LANG_SPECIFIC(NODE) (DECL_COMMON_CHECK (NODE)->decl_common.lang_specific) -/* In a VAR_DECL or FUNCTION_DECL, - nonzero means external reference: +/* In a VAR_DECL or FUNCTION_DECL, nonzero means external reference: do not allocate storage, and refer to a definition elsewhere. */ -#define DECL_EXTERNAL(NODE) (DECL_CHECK (NODE)->decl.external_flag) +#define DECL_EXTERNAL(NODE) (DECL_COMMON_CHECK (NODE)->decl_common.decl_flag_2) /* In a VAR_DECL for a RECORD_TYPE, sets number for non-init_priority initializations. */ @@ -2128,27 +2060,6 @@ extern void decl_debug_expr_insert (tree, tree); #define MAX_INIT_PRIORITY 65535 #define MAX_RESERVED_INIT_PRIORITY 100 -/* In a TYPE_DECL - nonzero means the detail info about this type is not dumped into stabs. - Instead it will generate cross reference ('x') of names. - This uses the same flag as DECL_EXTERNAL. */ -#define TYPE_DECL_SUPPRESS_DEBUG(NODE) \ - (TYPE_DECL_CHECK (NODE)->decl.external_flag) - -/* In VAR_DECL and PARM_DECL nodes, nonzero means declared `register'. */ -#define DECL_REGISTER(NODE) (DECL_CHECK (NODE)->decl.regdecl_flag) - -/* In LABEL_DECL nodes, nonzero means that an error message about - jumping into such a binding contour has been printed for this label. */ -#define DECL_ERROR_ISSUED(NODE) (LABEL_DECL_CHECK (NODE)->decl.regdecl_flag) - -/* In a FIELD_DECL, indicates this field should be bit-packed. */ -#define DECL_PACKED(NODE) (FIELD_DECL_CHECK (NODE)->decl.regdecl_flag) - -/* In a FUNCTION_DECL with a nonzero DECL_CONTEXT, indicates that a - static chain is not needed. */ -#define DECL_NO_STATIC_CHAIN(NODE) \ - (FUNCTION_DECL_CHECK (NODE)->decl.regdecl_flag) /* Nonzero in a ..._DECL means this variable is ref'd from a nested function. For VAR_DECL nodes, PARM_DECL nodes, and FUNCTION_DECL nodes. @@ -2157,51 +2068,120 @@ extern void decl_debug_expr_insert (tree, tree); Also set in some languages for variables, etc., outside the normal lexical scope, such as class instance variables. */ -#define DECL_NONLOCAL(NODE) (DECL_CHECK (NODE)->decl.nonlocal_flag) +#define DECL_NONLOCAL(NODE) (DECL_COMMON_CHECK (NODE)->decl_common.nonlocal_flag) -/* Nonzero in a FUNCTION_DECL means this function can be substituted - where it is called. */ -#define DECL_INLINE(NODE) (FUNCTION_DECL_CHECK (NODE)->decl.inline_flag) +/* Used in VAR_DECLs to indicate that the variable is a vtable. + Used in FIELD_DECLs for vtable pointers. + Used in FUNCTION_DECLs to indicate that the function is virtual. */ +#define DECL_VIRTUAL_P(NODE) (DECL_COMMON_CHECK (NODE)->decl_common.virtual_flag) -/* Nonzero in a FUNCTION_DECL means that this function was declared inline, - such as via the `inline' keyword in C/C++. This flag controls the linkage - semantics of 'inline'; whether or not the function is inlined is - controlled by DECL_INLINE. */ -#define DECL_DECLARED_INLINE_P(NODE) \ - (FUNCTION_DECL_CHECK (NODE)->decl.declared_inline_flag) +/* Used to indicate that this DECL represents a compiler-generated entity. */ +#define DECL_ARTIFICIAL(NODE) (DECL_COMMON_CHECK (NODE)->decl_common.artificial_flag) -/* Nonzero in a decl means that the gimplifier has seen (or placed) - this variable in a BIND_EXPR. */ -#define DECL_SEEN_IN_BIND_EXPR_P(NODE) \ - (DECL_CHECK (NODE)->decl.seen_in_bind_expr) +/* Additional flags for language-specific uses. */ +#define DECL_LANG_FLAG_0(NODE) (DECL_COMMON_CHECK (NODE)->decl_common.lang_flag_0) +#define DECL_LANG_FLAG_1(NODE) (DECL_COMMON_CHECK (NODE)->decl_common.lang_flag_1) +#define DECL_LANG_FLAG_2(NODE) (DECL_COMMON_CHECK (NODE)->decl_common.lang_flag_2) +#define DECL_LANG_FLAG_3(NODE) (DECL_COMMON_CHECK (NODE)->decl_common.lang_flag_3) +#define DECL_LANG_FLAG_4(NODE) (DECL_COMMON_CHECK (NODE)->decl_common.lang_flag_4) +#define DECL_LANG_FLAG_5(NODE) (DECL_COMMON_CHECK (NODE)->decl_common.lang_flag_5) +#define DECL_LANG_FLAG_6(NODE) (DECL_COMMON_CHECK (NODE)->decl_common.lang_flag_6) +#define DECL_LANG_FLAG_7(NODE) (DECL_COMMON_CHECK (NODE)->decl_common.lang_flag_7) -/* In a VAR_DECL, nonzero if the decl is a register variable with - an explicit asm specification. */ -#define DECL_HARD_REGISTER(NODE) (VAR_DECL_CHECK (NODE)->decl.inline_flag) +/* Used to indicate an alias set for the memory pointed to by this + particular FIELD_DECL, PARM_DECL, or VAR_DECL, which must have + pointer (or reference) type. */ +#define DECL_POINTER_ALIAS_SET(NODE) \ + (DECL_COMMON_CHECK (NODE)->decl_common.pointer_alias_set) -/* Value of the decls's visibility attribute */ -#define DECL_VISIBILITY(NODE) (DECL_CHECK (NODE)->decl.visibility) +/* Nonzero if an alias set has been assigned to this declaration. */ +#define DECL_POINTER_ALIAS_SET_KNOWN_P(NODE) \ + (DECL_POINTER_ALIAS_SET (NODE) != - 1) -/* Nonzero means that the decl had its visibility specified rather than - being inferred. */ -#define DECL_VISIBILITY_SPECIFIED(NODE) \ - (DECL_CHECK (NODE)->decl.visibility_specified) +/* Nonzero for a decl which is at file scope. */ +#define DECL_FILE_SCOPE_P(EXP) \ + (! DECL_CONTEXT (EXP) \ + || TREE_CODE (DECL_CONTEXT (EXP)) == TRANSLATION_UNIT_DECL) -/* In a FUNCTION_DECL, nonzero if the function cannot be inlined. */ -#define DECL_UNINLINABLE(NODE) (FUNCTION_DECL_CHECK (NODE)->decl.uninlinable) +/* Nonzero for a decl that is decorated using attribute used. + This indicates compiler tools that this decl needs to be preserved. */ +#define DECL_PRESERVE_P(DECL) \ + DECL_COMMON_CHECK (DECL)->decl_common.preserve_flag + +/* For function local variables of COMPLEX type, indicates that the + variable is not aliased, and that all modifications to the variable + have been adjusted so that they are killing assignments. Thus the + variable may now be treated as a GIMPLE register, and use real + instead of virtual ops in SSA form. */ +#define DECL_COMPLEX_GIMPLE_REG_P(DECL) \ + DECL_COMMON_CHECK (DECL)->decl_common.gimple_reg_flag -/* In a VAR_DECL, the model to use if the data should be allocated from - thread-local storage. */ -#define DECL_TLS_MODEL(NODE) (VAR_DECL_CHECK (NODE)->decl.tls_model) +struct tree_decl_common GTY(()) +{ + struct tree_decl_minimal common; + tree size; -/* In a VAR_DECL, nonzero if the data should be allocated from - thread-local storage. */ -#define DECL_THREAD_LOCAL_P(NODE) \ - (VAR_DECL_CHECK (NODE)->decl.tls_model != TLS_MODEL_NONE) + ENUM_BITFIELD(machine_mode) mode : 8; -/* In a FUNCTION_DECL, the saved representation of the body of the - entire function. */ -#define DECL_SAVED_TREE(NODE) (FUNCTION_DECL_CHECK (NODE)->decl.saved_tree) + unsigned nonlocal_flag : 1; + unsigned virtual_flag : 1; + unsigned ignored_flag : 1; + unsigned abstract_flag : 1; + unsigned artificial_flag : 1; + unsigned user_align : 1; + unsigned preserve_flag: 1; + unsigned debug_expr_is_from : 1; + + unsigned lang_flag_0 : 1; + unsigned lang_flag_1 : 1; + unsigned lang_flag_2 : 1; + unsigned lang_flag_3 : 1; + unsigned lang_flag_4 : 1; + unsigned lang_flag_5 : 1; + unsigned lang_flag_6 : 1; + unsigned lang_flag_7 : 1; + + /* In LABEL_DECL, this is DECL_ERROR_ISSUED. + In VAR_DECL and PARM_DECL, this is DECL_REGISTER. */ + unsigned decl_flag_0 : 1; + /* In FIELD_DECL, this is DECL_PACKED + In PARM_DECL, this is DECL_TRANSPARENT_UNION. */ + unsigned decl_flag_1 : 1; + /* In FIELD_DECL, this is DECL_BIT_FIELD + In VAR_DECL and FUNCTION_DECL, this is DECL_EXTERNAL. + In TYPE_DECL, this is TYPE_DECL_SUPRESS_DEBUG*/ + unsigned decl_flag_2 : 1; + /* In FIELD_DECL, this is DECL_NONADDRESSABLE_P + In VAR_DECL and PARM_DECL, this is DECL_HAS_VALUE_EXPR. */ + unsigned decl_flag_3 : 1; + /* Logically, this would go in a theoretical base shared by var and parm + decl. */ + unsigned gimple_reg_flag : 1; + + union tree_decl_u1 { + /* In a FUNCTION_DECL for which DECL_BUILT_IN holds, this is + DECL_FUNCTION_CODE. */ + enum built_in_function f; + /* In a FUNCTION_DECL for which DECL_BUILT_IN does not hold, this + is used by language-dependent code. */ + HOST_WIDE_INT i; + /* DECL_ALIGN and DECL_OFFSET_ALIGN. (These are not used for + FUNCTION_DECLs). */ + struct tree_decl_u1_a { + unsigned int align : 24; + unsigned int off_align : 8; + } a; + } GTY ((skip)) u1; + + tree size_unit; + tree initial; + tree attributes; + tree abstract_origin; + + HOST_WIDE_INT pointer_alias_set; + /* Points to a structure whose details depend on the language in use. */ + struct lang_decl *lang_specific; +}; extern tree decl_value_expr_lookup (tree); extern void decl_value_expr_insert (tree, tree); @@ -2211,80 +2191,185 @@ extern void decl_value_expr_insert (tree, tree); decl itself. This should only be used for debugging; once this field has been set, the decl itself may not legitimately appear in the function. */ #define DECL_HAS_VALUE_EXPR_P(NODE) \ - (TREE_CHECK2 (NODE, VAR_DECL, PARM_DECL)->decl.has_value_expr) + (TREE_CHECK2 (NODE, VAR_DECL, PARM_DECL)->decl_common.decl_flag_3) #define DECL_VALUE_EXPR(NODE) \ - (decl_value_expr_lookup (TREE_CHECK2 (NODE, VAR_DECL, PARM_DECL))) + (decl_value_expr_lookup (DECL_WRTL_CHECK (NODE))) #define SET_DECL_VALUE_EXPR(NODE, VAL) \ - (decl_value_expr_insert (TREE_CHECK2 (NODE, VAR_DECL, PARM_DECL), VAL)) + (decl_value_expr_insert (DECL_WRTL_CHECK (NODE), VAL)) -/* Nonzero in a FUNCTION_DECL means this function should be treated - as if it were a malloc, meaning it returns a pointer that is - not an alias. */ -#define DECL_IS_MALLOC(NODE) (FUNCTION_DECL_CHECK (NODE)->decl.malloc_flag) +/* Holds the RTL expression for the value of a variable or function. + This value can be evaluated lazily for functions, variables with + static storage duration, and labels. */ +#define DECL_RTL(NODE) \ + (DECL_WRTL_CHECK (NODE)->decl_with_rtl.rtl \ + ? (NODE)->decl_with_rtl.rtl \ + : (make_decl_rtl (NODE), (NODE)->decl_with_rtl.rtl)) -/* Nonzero in a FUNCTION_DECL means this function may return more - than once. */ -#define DECL_IS_RETURNS_TWICE(NODE) \ - (FUNCTION_DECL_CHECK (NODE)->decl.returns_twice_flag) +/* Set the DECL_RTL for NODE to RTL. */ +#define SET_DECL_RTL(NODE, RTL) set_decl_rtl (NODE, RTL) -/* Nonzero in a FUNCTION_DECL means this function should be treated - as "pure" function (like const function, but may read global memory). */ -#define DECL_IS_PURE(NODE) (FUNCTION_DECL_CHECK (NODE)->decl.pure_flag) +/* Returns nonzero if NODE is a tree node that can contain RTL. */ +#define HAS_RTL_P(NODE) (CODE_CONTAINS_STRUCT (TREE_CODE (NODE), TS_DECL_WRTL)) + +/* Returns nonzero if the DECL_RTL for NODE has already been set. */ +#define DECL_RTL_SET_P(NODE) (HAS_RTL_P (NODE) && DECL_WRTL_CHECK (NODE)->decl_with_rtl.rtl != NULL) + +/* Copy the RTL from NODE1 to NODE2. If the RTL was not set for + NODE1, it will not be set for NODE2; this is a lazy copy. */ +#define COPY_DECL_RTL(NODE1, NODE2) \ + (DECL_WRTL_CHECK (NODE2)->decl_with_rtl.rtl = DECL_WRTL_CHECK (NODE1)->decl_with_rtl.rtl) + +/* The DECL_RTL for NODE, if it is set, or NULL, if it is not set. */ +#define DECL_RTL_IF_SET(NODE) (DECL_RTL_SET_P (NODE) ? DECL_RTL (NODE) : NULL) + +/* In VAR_DECL and PARM_DECL nodes, nonzero means declared `register'. */ +#define DECL_REGISTER(NODE) (DECL_WRTL_CHECK (NODE)->decl_common.decl_flag_0) + +struct tree_decl_with_rtl GTY(()) +{ + struct tree_decl_common common; + rtx rtl; +}; + +/* In a FIELD_DECL, this is the field position, counting in bytes, of the + byte containing the bit closest to the beginning of the structure. */ +#define DECL_FIELD_OFFSET(NODE) (FIELD_DECL_CHECK (NODE)->field_decl.offset) + +/* In a FIELD_DECL, this is the offset, in bits, of the first bit of the + field from DECL_FIELD_OFFSET. */ +#define DECL_FIELD_BIT_OFFSET(NODE) (FIELD_DECL_CHECK (NODE)->field_decl.bit_offset) + +/* In a FIELD_DECL, this indicates whether the field was a bit-field and + if so, the type that was originally specified for it. + TREE_TYPE may have been modified (in finish_struct). */ +#define DECL_BIT_FIELD_TYPE(NODE) (FIELD_DECL_CHECK (NODE)->field_decl.bit_field_type) + +/* For a FIELD_DECL in a QUAL_UNION_TYPE, records the expression, which + if nonzero, indicates that the field occupies the type. */ +#define DECL_QUALIFIER(NODE) (FIELD_DECL_CHECK (NODE)->field_decl.qualifier) + +/* For FIELD_DECLs, off_align holds the number of low-order bits of + DECL_FIELD_OFFSET which are known to be always zero. + DECL_OFFSET_ALIGN thus returns the alignment that DECL_FIELD_OFFSET + has. */ +#define DECL_OFFSET_ALIGN(NODE) \ + (((unsigned HOST_WIDE_INT)1) << FIELD_DECL_CHECK (NODE)->decl_common.u1.a.off_align) + +/* Specify that DECL_ALIGN(NODE) is a multiple of X. */ +#define SET_DECL_OFFSET_ALIGN(NODE, X) \ + (FIELD_DECL_CHECK (NODE)->decl_common.u1.a.off_align = exact_log2 ((X) & -(X))) +/* 1 if the alignment for this type was requested by "aligned" attribute, + 0 if it is the default for this type. */ + +/* For FIELD_DECLS, DECL_FCONTEXT is the *first* baseclass in + which this FIELD_DECL is defined. This information is needed when + writing debugging information about vfield and vbase decls for C++. */ +#define DECL_FCONTEXT(NODE) (FIELD_DECL_CHECK (NODE)->field_decl.fcontext) + +/* In a FIELD_DECL, indicates this field should be bit-packed. */ +#define DECL_PACKED(NODE) (FIELD_DECL_CHECK (NODE)->decl_common.decl_flag_1) -/* Nonzero in a FUNCTION_DECL means this function should be treated - as "novops" function (function that does not read global memory, - but may have arbitrary side effects). */ -#define DECL_IS_NOVOPS(NODE) (FUNCTION_DECL_CHECK (NODE)->decl.novops_flag) - /* Nonzero in a FIELD_DECL means it is a bit field, and must be accessed specially. */ -#define DECL_BIT_FIELD(NODE) (FIELD_DECL_CHECK (NODE)->decl.bit_field_flag) +#define DECL_BIT_FIELD(NODE) (FIELD_DECL_CHECK (NODE)->decl_common.decl_flag_2) -/* Unused in FUNCTION_DECL. */ +/* Used in a FIELD_DECL to indicate that we cannot form the address of + this component. */ +#define DECL_NONADDRESSABLE_P(NODE) \ + (FIELD_DECL_CHECK (NODE)->decl_common.decl_flag_3) -/* In a VAR_DECL that's static, - nonzero if the space is in the text section. */ -#define DECL_IN_TEXT_SECTION(NODE) (VAR_DECL_CHECK (NODE)->decl.bit_field_flag) +struct tree_field_decl GTY(()) +{ + struct tree_decl_common common; + + tree offset; + tree bit_field_type; + tree qualifier; + tree bit_offset; + tree fcontext; + +}; -/* In a FUNCTION_DECL, nonzero means a built in function. */ -#define DECL_BUILT_IN(NODE) (DECL_BUILT_IN_CLASS (NODE) != NOT_BUILT_IN) +/* A numeric unique identifier for a LABEL_DECL. The UID allocation is + dense, unique within any one function, and may be used to index arrays. + If the value is -1, then no UID has been assigned. */ +#define LABEL_DECL_UID(NODE) \ + (LABEL_DECL_CHECK (NODE)->decl_common.pointer_alias_set) -/* For a builtin function, identify which part of the compiler defined it. */ -#define DECL_BUILT_IN_CLASS(NODE) \ - (FUNCTION_DECL_CHECK (NODE)->decl.built_in_class) +/* In LABEL_DECL nodes, nonzero means that an error message about + jumping into such a binding contour has been printed for this label. */ +#define DECL_ERROR_ISSUED(NODE) (LABEL_DECL_CHECK (NODE)->decl_common.decl_flag_0) -/* Used in VAR_DECLs to indicate that the variable is a vtable. - Used in FIELD_DECLs for vtable pointers. - Used in FUNCTION_DECLs to indicate that the function is virtual. */ -#define DECL_VIRTUAL_P(NODE) (DECL_CHECK (NODE)->decl.virtual_flag) +struct tree_label_decl GTY(()) +{ + struct tree_decl_with_rtl common; + /* Java's verifier has some need to store information about labels, + and was using fields that no longer exist on labels. + Once the verifier doesn't need these anymore, they should be removed. */ + tree java_field_1; + tree java_field_2; + tree java_field_3; + unsigned int java_field_4; -/* Used to indicate that the linkage status of this DECL is not yet known, - so it should not be output now. */ -#define DECL_DEFER_OUTPUT(NODE) (DECL_CHECK (NODE)->decl.defer_output) +}; + +struct tree_result_decl GTY(()) +{ + struct tree_decl_with_rtl common; +}; + +struct tree_const_decl GTY(()) +{ + struct tree_decl_with_rtl common; +}; + +/* For a PARM_DECL, records the data type used to pass the argument, + which may be different from the type seen in the program. */ +#define DECL_ARG_TYPE(NODE) (PARM_DECL_CHECK (NODE)->decl_common.initial) + +/* For PARM_DECL, holds an RTL for the stack slot or register + where the data was actually passed. */ +#define DECL_INCOMING_RTL(NODE) (PARM_DECL_CHECK (NODE)->parm_decl.incoming_rtl) /* Used in PARM_DECLs whose type are unions to indicate that the argument should be passed in the same way that the first union alternative would be passed. */ #define DECL_TRANSPARENT_UNION(NODE) \ - (PARM_DECL_CHECK (NODE)->decl.transparent_union) + (PARM_DECL_CHECK (NODE)->decl_common.decl_flag_1) -/* Used in FUNCTION_DECLs to indicate that they should be run automatically - at the beginning or end of execution. */ -#define DECL_STATIC_CONSTRUCTOR(NODE) \ - (FUNCTION_DECL_CHECK (NODE)->decl.static_ctor_flag) +struct tree_parm_decl GTY(()) +{ + struct tree_decl_with_rtl common; + rtx incoming_rtl; +}; -#define DECL_STATIC_DESTRUCTOR(NODE) \ -(FUNCTION_DECL_CHECK (NODE)->decl.static_dtor_flag) -/* Used to indicate that this DECL represents a compiler-generated entity. */ -#define DECL_ARTIFICIAL(NODE) (DECL_CHECK (NODE)->decl.artificial_flag) +/* Nonzero in a decl means that the gimplifier has seen (or placed) + this variable in a BIND_EXPR. */ +#define DECL_SEEN_IN_BIND_EXPR_P(NODE) \ + (DECL_WITH_VIS_CHECK (NODE)->decl_with_vis.seen_in_bind_expr) -/* Used to indicate that this DECL has weak linkage. */ -#define DECL_WEAK(NODE) (DECL_CHECK (NODE)->decl.weak_flag) +/* Used to indicate that the linkage status of this DECL is not yet known, + so it should not be output now. */ +#define DECL_DEFER_OUTPUT(NODE) (DECL_WITH_VIS_CHECK (NODE)->decl_with_vis.defer_output) + +/* Nonzero for a given ..._DECL node means that no warnings should be + generated just because this node is unused. */ +#define DECL_IN_SYSTEM_HEADER(NODE) \ + (DECL_WITH_VIS_CHECK (NODE)->decl_with_vis.in_system_header_flag) + + /* Used to indicate that this DECL has weak linkage. */ +#define DECL_WEAK(NODE) (DECL_WITH_VIS_CHECK (NODE)->decl_with_vis.weak_flag) + +/* Internal to the gimplifier. Indicates that the value is a formal + temporary controlled by the gimplifier. */ +#define DECL_GIMPLE_FORMAL_TEMP_P(DECL) \ + DECL_WITH_VIS_CHECK (DECL)->decl_with_vis.gimple_formal_temp + +/* Used to indicate that the pointer to this DECL cannot be treated as + an address constant. */ +#define DECL_NON_ADDR_CONST_P(NODE) (DECL_WITH_VIS_CHECK (NODE)->decl_with_vis.non_addr_const_p) -/* Used in TREE_PUBLIC decls to indicate that copies of this DECL in - multiple translation units should be merged. */ -#define DECL_ONE_ONLY(NODE) (DECL_CHECK (NODE)->decl.transparent_union) /* Used in a DECL to indicate that, even if it TREE_PUBLIC, it need not be put out unless it is needed in this translation unit. @@ -2295,210 +2380,300 @@ extern void decl_value_expr_insert (tree, tree); back-end; it is up to front-ends which set this flag to ensure that there will never be any harm, other than bloat, in putting out something which is DECL_COMDAT. */ -#define DECL_COMDAT(NODE) (DECL_CHECK (NODE)->decl.comdat_flag) +#define DECL_COMDAT(NODE) (DECL_WITH_VIS_CHECK (NODE)->decl_with_vis.comdat_flag) -/* Used in FUNCTION_DECLs to indicate that function entry and exit should - be instrumented with calls to support routines. */ -#define DECL_NO_INSTRUMENT_FUNCTION_ENTRY_EXIT(NODE) \ - (FUNCTION_DECL_CHECK (NODE)->decl.no_instrument_function_entry_exit) +/* The name of the object as the assembler will see it (but before any + translations made by ASM_OUTPUT_LABELREF). Often this is the same + as DECL_NAME. It is an IDENTIFIER_NODE. */ +#define DECL_ASSEMBLER_NAME(NODE) decl_assembler_name (NODE) -/* Used in FUNCTION_DECLs to indicate that limit-stack-* should be - disabled in this function. */ -#define DECL_NO_LIMIT_STACK(NODE) \ - (FUNCTION_DECL_CHECK (NODE)->decl.no_limit_stack) +/* Return true if NODE is a NODE that can contain a DECL_ASSEMBLER_NAME. + This is true of all DECL nodes except FIELD_DECL. */ +#define HAS_DECL_ASSEMBLER_NAME_P(NODE) \ + (CODE_CONTAINS_STRUCT (TREE_CODE (NODE), TS_DECL_WITH_VIS)) -/* Additional flags for language-specific uses. */ -#define DECL_LANG_FLAG_0(NODE) (DECL_CHECK (NODE)->decl.lang_flag_0) -#define DECL_LANG_FLAG_1(NODE) (DECL_CHECK (NODE)->decl.lang_flag_1) -#define DECL_LANG_FLAG_2(NODE) (DECL_CHECK (NODE)->decl.lang_flag_2) -#define DECL_LANG_FLAG_3(NODE) (DECL_CHECK (NODE)->decl.lang_flag_3) -#define DECL_LANG_FLAG_4(NODE) (DECL_CHECK (NODE)->decl.lang_flag_4) -#define DECL_LANG_FLAG_5(NODE) (DECL_CHECK (NODE)->decl.lang_flag_5) -#define DECL_LANG_FLAG_6(NODE) (DECL_CHECK (NODE)->decl.lang_flag_6) -#define DECL_LANG_FLAG_7(NODE) (DECL_CHECK (NODE)->decl.lang_flag_7) +/* Returns nonzero if the DECL_ASSEMBLER_NAME for NODE has been set. If zero, + the NODE might still have a DECL_ASSEMBLER_NAME -- it just hasn't been set + yet. */ +#define DECL_ASSEMBLER_NAME_SET_P(NODE) \ + (HAS_DECL_ASSEMBLER_NAME_P (NODE) && DECL_WITH_VIS_CHECK (NODE)->decl_with_vis.assembler_name != NULL_TREE) -/* Used to indicate that the pointer to this DECL cannot be treated as - an address constant. */ -#define DECL_NON_ADDR_CONST_P(NODE) (DECL_CHECK (NODE)->decl.non_addr_const_p) +/* Set the DECL_ASSEMBLER_NAME for NODE to NAME. */ +#define SET_DECL_ASSEMBLER_NAME(NODE, NAME) \ + (DECL_WITH_VIS_CHECK (NODE)->decl_with_vis.assembler_name = (NAME)) -/* Used in a FIELD_DECL to indicate that we cannot form the address of - this component. */ -#define DECL_NONADDRESSABLE_P(NODE) \ - (FIELD_DECL_CHECK (NODE)->decl.non_addressable) +/* Copy the DECL_ASSEMBLER_NAME from DECL1 to DECL2. Note that if DECL1's + DECL_ASSEMBLER_NAME has not yet been set, using this macro will not cause + the DECL_ASSEMBLER_NAME of either DECL to be set. In other words, the + semantics of using this macro, are different than saying: -/* Used to indicate an alias set for the memory pointed to by this - particular FIELD_DECL, PARM_DECL, or VAR_DECL, which must have - pointer (or reference) type. */ -#define DECL_POINTER_ALIAS_SET(NODE) \ - (DECL_CHECK (NODE)->decl.pointer_alias_set) + SET_DECL_ASSEMBLER_NAME(DECL2, DECL_ASSEMBLER_NAME (DECL1)) + which will try to set the DECL_ASSEMBLER_NAME for DECL1. */ -/* A numeric unique identifier for a LABEL_DECL. The UID allocation is - dense, unique within any one function, and may be used to index arrays. - If the value is -1, then no UID has been assigned. */ -#define LABEL_DECL_UID(NODE) \ - (LABEL_DECL_CHECK (NODE)->decl.pointer_alias_set) +#define COPY_DECL_ASSEMBLER_NAME(DECL1, DECL2) \ + (DECL_ASSEMBLER_NAME_SET_P (DECL1) \ + ? (void) SET_DECL_ASSEMBLER_NAME (DECL2, \ + DECL_ASSEMBLER_NAME (DECL1)) \ + : (void) 0) -/* Nonzero if an alias set has been assigned to this declaration. */ -#define DECL_POINTER_ALIAS_SET_KNOWN_P(NODE) \ - (DECL_POINTER_ALIAS_SET (NODE) != - 1) +/* Records the section name in a section attribute. Used to pass + the name from decl_attributes to make_function_rtl and make_decl_rtl. */ +#define DECL_SECTION_NAME(NODE) (DECL_WITH_VIS_CHECK (NODE)->decl_with_vis.section_name) -/* Nonzero for a decl which is at file scope. */ -#define DECL_FILE_SCOPE_P(EXP) \ - (! DECL_CONTEXT (EXP) \ - || TREE_CODE (DECL_CONTEXT (EXP)) == TRANSLATION_UNIT_DECL) +/* Value of the decls's visibility attribute */ +#define DECL_VISIBILITY(NODE) (DECL_WITH_VIS_CHECK (NODE)->decl_with_vis.visibility) + +/* Nonzero means that the decl had its visibility specified rather than + being inferred. */ +#define DECL_VISIBILITY_SPECIFIED(NODE) (DECL_WITH_VIS_CHECK (NODE)->decl_with_vis.visibility_specified) + +/* Used in TREE_PUBLIC decls to indicate that copies of this DECL in + multiple translation units should be merged. */ +#define DECL_ONE_ONLY(NODE) (DECL_WITH_VIS_CHECK (NODE)->decl_with_vis.one_only) + +struct tree_decl_with_vis GTY(()) +{ + struct tree_decl_with_rtl common; + tree assembler_name; + tree section_name; + + /* Belong to VAR_DECL exclusively. */ + unsigned defer_output:1; + unsigned hard_register:1; + unsigned thread_local:1; + unsigned common_flag:1; + unsigned in_text_section : 1; + unsigned gimple_formal_temp : 1; + unsigned non_addr_const_p : 1; + /* Used by C++. Might become a generic decl flag. */ + unsigned shadowed_for_var_p : 1; + + /* Don't belong to VAR_DECL exclusively. */ + unsigned in_system_header_flag : 1; + unsigned weak_flag:1; + unsigned seen_in_bind_expr : 1; + unsigned comdat_flag : 1; + ENUM_BITFIELD(symbol_visibility) visibility : 2; + unsigned visibility_specified : 1; + /* Belong to FUNCTION_DECL exclusively. */ + unsigned one_only : 1; + unsigned init_priority_p:1; + + /* Belongs to VAR_DECL exclusively. */ + ENUM_BITFIELD(tls_model) tls_model : 3; + /* 13 unused bits. */ +}; + +/* In a VAR_DECL that's static, + nonzero if the space is in the text section. */ +#define DECL_IN_TEXT_SECTION(NODE) (VAR_DECL_CHECK (NODE)->decl_with_vis.in_text_section) + +/* Nonzero for a given ..._DECL node means that this node should be + put in .common, if possible. If a DECL_INITIAL is given, and it + is not error_mark_node, then the decl cannot be put in .common. */ +#define DECL_COMMON(NODE) (DECL_WITH_VIS_CHECK (NODE)->decl_with_vis.common_flag) + +/* In a VAR_DECL, nonzero if the decl is a register variable with + an explicit asm specification. */ +#define DECL_HARD_REGISTER(NODE) (VAR_DECL_CHECK (NODE)->decl_with_vis.hard_register) + +extern tree decl_debug_expr_lookup (tree); +extern void decl_debug_expr_insert (tree, tree); +/* For VAR_DECL, this is set to either an expression that it was split + from (if DECL_DEBUG_EXPR_IS_FROM is true), otherwise a tree_list of + subexpressions that it was split into. */ +#define DECL_DEBUG_EXPR(NODE) \ + (decl_debug_expr_lookup (VAR_DECL_CHECK (NODE))) + +#define SET_DECL_DEBUG_EXPR(NODE, VAL) \ + (decl_debug_expr_insert (VAR_DECL_CHECK (NODE), VAL)) + + +extern unsigned short decl_init_priority_lookup (tree); +extern void decl_init_priority_insert (tree, unsigned short); + +/* In a non-local VAR_DECL with static storage duration, this is the + initialization priority. If this value is zero, the NODE will be + initialized at the DEFAULT_INIT_PRIORITY. Only used by C++ FE*/ + +#define DECL_HAS_INIT_PRIORITY_P(NODE) \ + (VAR_DECL_CHECK (NODE)->decl_with_vis.init_priority_p) +#define DECL_INIT_PRIORITY(NODE) \ + (decl_init_priority_lookup (VAR_DECL_CHECK (NODE))) +#define SET_DECL_INIT_PRIORITY(NODE, VAL) \ + (decl_init_priority_insert (VAR_DECL_CHECK (NODE), VAL)) + +/* In a VAR_DECL, the model to use if the data should be allocated from + thread-local storage. */ +#define DECL_TLS_MODEL(NODE) (VAR_DECL_CHECK (NODE)->decl_with_vis.tls_model) + +/* In a VAR_DECL, nonzero if the data should be allocated from + thread-local storage. */ +#define DECL_THREAD_LOCAL_P(NODE) \ + (VAR_DECL_CHECK (NODE)->decl_with_vis.tls_model != TLS_MODEL_NONE) + +struct tree_var_decl GTY(()) +{ + struct tree_decl_with_vis common; +}; + + +/* This field is used to reference anything in decl.result and is meant only + for use by the garbage collector. */ +#define DECL_RESULT_FLD(NODE) (DECL_NON_COMMON_CHECK (NODE)->decl_non_common.result) + +/* The DECL_VINDEX is used for FUNCTION_DECLS in two different ways. + Before the struct containing the FUNCTION_DECL is laid out, + DECL_VINDEX may point to a FUNCTION_DECL in a base class which + is the FUNCTION_DECL which this FUNCTION_DECL will replace as a virtual + function. When the class is laid out, this pointer is changed + to an INTEGER_CST node which is suitable for use as an index + into the virtual function table. + C++ also uses this field in namespaces, hence the DECL_NON_COMMON_CHECK. */ +#define DECL_VINDEX(NODE) (DECL_NON_COMMON_CHECK (NODE)->decl_non_common.vindex) + +struct tree_decl_non_common GTY(()) + +{ + struct tree_decl_with_vis common; + /* C++ uses this in namespaces. */ + tree saved_tree; + /* C++ uses this in templates. */ + tree arguments; + /* Almost all FE's use this. */ + tree result; + /* C++ uses this in namespaces. */ + tree vindex; +}; + +/* In FUNCTION_DECL, holds the decl for the return value. */ +#define DECL_RESULT(NODE) (FUNCTION_DECL_CHECK (NODE)->decl_non_common.result) + +/* In a FUNCTION_DECL, nonzero if the function cannot be inlined. */ +#define DECL_UNINLINABLE(NODE) (FUNCTION_DECL_CHECK (NODE)->function_decl.uninlinable) + +/* In a FUNCTION_DECL, the saved representation of the body of the + entire function. */ +#define DECL_SAVED_TREE(NODE) (FUNCTION_DECL_CHECK (NODE)->decl_non_common.saved_tree) + +/* Nonzero in a FUNCTION_DECL means this function should be treated + as if it were a malloc, meaning it returns a pointer that is + not an alias. */ +#define DECL_IS_MALLOC(NODE) (FUNCTION_DECL_CHECK (NODE)->function_decl.malloc_flag) + +/* Nonzero in a FUNCTION_DECL means this function may return more + than once. */ +#define DECL_IS_RETURNS_TWICE(NODE) \ + (FUNCTION_DECL_CHECK (NODE)->function_decl.returns_twice_flag) + +/* Nonzero in a FUNCTION_DECL means this function should be treated + as "pure" function (like const function, but may read global memory). */ +#define DECL_IS_PURE(NODE) (FUNCTION_DECL_CHECK (NODE)->function_decl.pure_flag) + +/* Nonzero in a FUNCTION_DECL means this function should be treated + as "novops" function (function that does not read global memory, + but may have arbitrary side effects). */ +#define DECL_IS_NOVOPS(NODE) (FUNCTION_DECL_CHECK (NODE)->function_decl.novops_flag) + +/* Used in FUNCTION_DECLs to indicate that they should be run automatically + at the beginning or end of execution. */ +#define DECL_STATIC_CONSTRUCTOR(NODE) \ + (FUNCTION_DECL_CHECK (NODE)->function_decl.static_ctor_flag) + +#define DECL_STATIC_DESTRUCTOR(NODE) \ +(FUNCTION_DECL_CHECK (NODE)->function_decl.static_dtor_flag) + +/* Used in FUNCTION_DECLs to indicate that function entry and exit should + be instrumented with calls to support routines. */ +#define DECL_NO_INSTRUMENT_FUNCTION_ENTRY_EXIT(NODE) \ + (FUNCTION_DECL_CHECK (NODE)->function_decl.no_instrument_function_entry_exit) + +/* Used in FUNCTION_DECLs to indicate that limit-stack-* should be + disabled in this function. */ +#define DECL_NO_LIMIT_STACK(NODE) \ + (FUNCTION_DECL_CHECK (NODE)->function_decl.no_limit_stack) + +/* In a FUNCTION_DECL with a nonzero DECL_CONTEXT, indicates that a + static chain is not needed. */ +#define DECL_NO_STATIC_CHAIN(NODE) \ + (FUNCTION_DECL_CHECK (NODE)->function_decl.regdecl_flag) /* Nonzero for a decl that cgraph has decided should be inlined into at least one call site. It is not meaningful to look at this directly; always use cgraph_function_possibly_inlined_p. */ #define DECL_POSSIBLY_INLINED(DECL) \ - FUNCTION_DECL_CHECK (DECL)->decl.possibly_inlined + FUNCTION_DECL_CHECK (DECL)->function_decl.possibly_inlined -/* Nonzero for a decl that is decorated using attribute used. - This indicates compiler tools that this decl needs to be preserved. */ -#define DECL_PRESERVE_P(DECL) \ - DECL_CHECK (DECL)->decl.preserve_flag +/* Nonzero in a FUNCTION_DECL means this function can be substituted + where it is called. */ +#define DECL_INLINE(NODE) (FUNCTION_DECL_CHECK (NODE)->function_decl.inline_flag) -/* Internal to the gimplifier. Indicates that the value is a formal - temporary controlled by the gimplifier. */ -#define DECL_GIMPLE_FORMAL_TEMP_P(DECL) \ - DECL_CHECK (DECL)->decl.gimple_formal_temp +/* Nonzero in a FUNCTION_DECL means that this function was declared inline, + such as via the `inline' keyword in C/C++. This flag controls the linkage + semantics of 'inline'; whether or not the function is inlined is + controlled by DECL_INLINE. */ +#define DECL_DECLARED_INLINE_P(NODE) \ + (FUNCTION_DECL_CHECK (NODE)->function_decl.declared_inline_flag) -/* For function local variables of COMPLEX type, indicates that the - variable is not aliased, and that all modifications to the variable - have been adjusted so that they are killing assignments. Thus the - variable may now be treated as a GIMPLE register, and use real - instead of virtual ops in SSA form. */ -#define DECL_COMPLEX_GIMPLE_REG_P(DECL) \ - DECL_CHECK (DECL)->decl.gimple_reg_flag +/* For FUNCTION_DECL, this holds a pointer to a structure ("struct function") + that describes the status of this function. */ +#define DECL_STRUCT_FUNCTION(NODE) (FUNCTION_DECL_CHECK (NODE)->function_decl.f) -/* Enumerate visibility settings. */ -#ifndef SYMBOL_VISIBILITY_DEFINED -#define SYMBOL_VISIBILITY_DEFINED -enum symbol_visibility -{ - VISIBILITY_DEFAULT, - VISIBILITY_INTERNAL, - VISIBILITY_HIDDEN, - VISIBILITY_PROTECTED -}; -#endif +/* In a FUNCTION_DECL, nonzero means a built in function. */ +#define DECL_BUILT_IN(NODE) (DECL_BUILT_IN_CLASS (NODE) != NOT_BUILT_IN) -struct function; -struct tree_decl GTY(()) -{ - struct tree_common common; - location_t locus; - unsigned int uid; - tree size; +/* For a builtin function, identify which part of the compiler defined it. */ +#define DECL_BUILT_IN_CLASS(NODE) \ + (FUNCTION_DECL_CHECK (NODE)->function_decl.built_in_class) - /* 32 bits: */ - ENUM_BITFIELD(machine_mode) mode : 8; +/* In FUNCTION_DECL, a chain of ..._DECL nodes. + VAR_DECL and PARM_DECL reserve the arguments slot for language-specific + uses. */ +#define DECL_ARGUMENTS(NODE) (FUNCTION_DECL_CHECK (NODE)->decl_non_common.arguments) - unsigned external_flag : 1; - unsigned nonlocal_flag : 1; - unsigned regdecl_flag : 1; - unsigned inline_flag : 1; - unsigned bit_field_flag : 1; - unsigned virtual_flag : 1; - unsigned ignored_flag : 1; - unsigned abstract_flag : 1; +/* FUNCTION_DECL inherits from DECL_NON_COMMON because of the use of the + arguments/result/saved_tree fields by front ends. It was either inherit + FUNCTION_DECL from non_common, or inherit non_common from FUNCTION_DECL, + which seemed a bit strange. */ - unsigned in_system_header_flag : 1; - unsigned common_flag : 1; - unsigned defer_output : 1; - unsigned transparent_union : 1; +struct tree_function_decl GTY(()) +{ + struct tree_decl_non_common common; + unsigned static_ctor_flag : 1; unsigned static_dtor_flag : 1; - unsigned artificial_flag : 1; - unsigned weak_flag : 1; - - unsigned non_addr_const_p : 1; - unsigned no_instrument_function_entry_exit : 1; - unsigned comdat_flag : 1; + unsigned uninlinable : 1; + unsigned possibly_inlined : 1; + unsigned novops_flag : 1; + unsigned returns_twice_flag : 1; unsigned malloc_flag : 1; - unsigned no_limit_stack : 1; - ENUM_BITFIELD(built_in_class) built_in_class : 2; unsigned pure_flag : 1; - - /* 32 bits: */ - unsigned non_addressable : 1; - unsigned user_align : 1; - unsigned uninlinable : 1; - unsigned gimple_reg_flag : 1; + unsigned declared_inline_flag : 1; - ENUM_BITFIELD(symbol_visibility) visibility : 2; - unsigned visibility_specified : 1; + unsigned regdecl_flag : 1; + unsigned inline_flag : 1; + unsigned no_instrument_function_entry_exit : 1; + unsigned no_limit_stack : 1; + ENUM_BITFIELD(built_in_class) built_in_class : 2; - unsigned lang_flag_0 : 1; - unsigned lang_flag_1 : 1; - unsigned lang_flag_2 : 1; - unsigned lang_flag_3 : 1; - unsigned lang_flag_4 : 1; - unsigned lang_flag_5 : 1; - unsigned lang_flag_6 : 1; - unsigned lang_flag_7 : 1; + struct function *f; +}; - unsigned possibly_inlined : 1; - unsigned preserve_flag: 1; - unsigned gimple_formal_temp : 1; - unsigned debug_expr_is_from : 1; - unsigned returns_twice_flag : 1; - unsigned seen_in_bind_expr : 1; - unsigned novops_flag : 1; - unsigned has_value_expr : 1; +/* For a TYPE_DECL, holds the "original" type. (TREE_TYPE has the copy.) */ +#define DECL_ORIGINAL_TYPE(NODE) (TYPE_DECL_CHECK (NODE)->decl_non_common.result) - ENUM_BITFIELD(tls_model) tls_model : 3; - /* 5 unused bits. */ +/* In a TYPE_DECL nonzero means the detail info about this type is not dumped + into stabs. Instead it will generate cross reference ('x') of names. + This uses the same flag as DECL_EXTERNAL. */ +#define TYPE_DECL_SUPPRESS_DEBUG(NODE) \ + (TYPE_DECL_CHECK (NODE)->decl_common.decl_flag_2) - union tree_decl_u1 { - /* In a FUNCTION_DECL for which DECL_BUILT_IN holds, this is - DECL_FUNCTION_CODE. */ - enum built_in_function f; - /* In a FUNCTION_DECL for which DECL_BUILT_IN does not hold, this - is used by language-dependent code. */ - HOST_WIDE_INT i; - /* DECL_ALIGN and DECL_OFFSET_ALIGN. (These are not used for - FUNCTION_DECLs). */ - struct tree_decl_u1_a { - unsigned int align : 24; - unsigned int off_align : 8; - } a; - } GTY ((skip)) u1; +struct tree_type_decl GTY(()) +{ + struct tree_decl_non_common common; - tree size_unit; - tree name; - tree context; - tree arguments; /* Also used for DECL_FIELD_OFFSET */ - tree result; /* Also used for DECL_BIT_FIELD_TYPE */ - tree initial; /* Also used for DECL_QUALIFIER */ - tree abstract_origin; - tree assembler_name; - tree section_name; - tree attributes; - rtx rtl; /* RTL representation for object. */ - - /* In FUNCTION_DECL, if it is inline, holds the saved insn chain. - In FIELD_DECL, is DECL_FIELD_BIT_OFFSET. - In PARM_DECL, holds an RTL for the stack slot - of register where the data was actually passed. - Used by Chill and Java in LABEL_DECL and by C++ and Java in VAR_DECL. */ - union tree_decl_u2 { - struct function * GTY ((tag ("FUNCTION_DECL"))) f; - rtx GTY ((tag ("PARM_DECL"))) r; - tree GTY ((tag ("FIELD_DECL"))) t; - int GTY ((tag ("VAR_DECL"))) i; - } GTY ((desc ("TREE_CODE((tree) &(%0))"))) u2; - - /* In a FUNCTION_DECL, this is DECL_SAVED_TREE. - In a VAR_DECL or PARM_DECL, this is DECL_VALUE_EXPR. */ - tree saved_tree; - tree vindex; - HOST_WIDE_INT pointer_alias_set; - /* Points to a structure whose details depend on the language in use. */ - struct lang_decl *lang_specific; }; - /* A STATEMENT_LIST chains statements together in GENERIC and GIMPLE. To reduce overhead, the nodes containing the statements are not trees. @@ -2549,27 +2724,7 @@ struct tree_value_handle GTY(()) unsigned int id; }; -enum tree_node_structure_enum { - TS_COMMON, - TS_INT_CST, - TS_REAL_CST, - TS_VECTOR, - TS_STRING, - TS_COMPLEX, - TS_IDENTIFIER, - TS_DECL, - TS_TYPE, - TS_LIST, - TS_VEC, - TS_EXP, - TS_SSA_NAME, - TS_PHI_NODE, - TS_BLOCK, - TS_BINFO, - TS_STATEMENT_LIST, - TS_VALUE_HANDLE, - LAST_TS_ENUM -}; + /* Define the overall contents of a tree node. It may be any of the structures declared above @@ -2585,7 +2740,19 @@ union tree_node GTY ((ptr_alias (union lang_tree_node), struct tree_string GTY ((tag ("TS_STRING"))) string; struct tree_complex GTY ((tag ("TS_COMPLEX"))) complex; struct tree_identifier GTY ((tag ("TS_IDENTIFIER"))) identifier; - struct tree_decl GTY ((tag ("TS_DECL"))) decl; + struct tree_decl_minimal GTY((tag ("TS_DECL_MINIMAL"))) decl_minimal; + struct tree_decl_common GTY ((tag ("TS_DECL_COMMON"))) decl_common; + struct tree_decl_with_rtl GTY ((tag ("TS_DECL_WRTL"))) decl_with_rtl; + struct tree_decl_non_common GTY ((tag ("TS_DECL_NON_COMMON"))) decl_non_common; + struct tree_parm_decl GTY ((tag ("TS_PARM_DECL"))) parm_decl; + struct tree_decl_with_vis GTY ((tag ("TS_DECL_WITH_VIS"))) decl_with_vis; + struct tree_var_decl GTY ((tag ("TS_VAR_DECL"))) var_decl; + struct tree_field_decl GTY ((tag ("TS_FIELD_DECL"))) field_decl; + struct tree_label_decl GTY ((tag ("TS_LABEL_DECL"))) label_decl; + struct tree_result_decl GTY ((tag ("TS_RESULT_DECL"))) result_decl; + struct tree_const_decl GTY ((tag ("TS_CONST_DECL"))) const_decl; + struct tree_type_decl GTY ((tag ("TS_TYPE_DECL"))) type_decl; + struct tree_function_decl GTY ((tag ("TS_FUNCTION_DECL"))) function_decl; struct tree_type GTY ((tag ("TS_TYPE"))) type; struct tree_list GTY ((tag ("TS_LIST"))) list; struct tree_vec GTY ((tag ("TS_VEC"))) vec; @@ -3933,6 +4100,17 @@ extern tree get_base_address (tree t); /* In tree-vectorizer.c. */ extern void vect_set_verbosity_level (const char *); +struct tree_map GTY(()) +{ + unsigned int hash; + tree from; + tree to; +}; + +extern unsigned int tree_map_hash (const void *); +extern int tree_map_marked_p (const void *); +extern int tree_map_eq (const void *, const void *); + /* In tree-ssa-address.c. */ extern tree tree_mem_ref_addr (tree, tree); extern void copy_mem_ref_info (tree, tree); diff --git a/gcc/treestruct.def b/gcc/treestruct.def new file mode 100644 index 00000000000..43a465d4ea7 --- /dev/null +++ b/gcc/treestruct.def @@ -0,0 +1,60 @@ +/* This file contains the definitions for the tree structure + enumeration used in GCC. + +Copyright (C) 2005 Free Software Foundation, Inc. + +This file is part of GCC. + +GCC is free software; you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free +Software Foundation; either version 2, or (at your option) any later +version. + +GCC is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with GCC; see the file COPYING. If not, write to the Free +Software Foundation, 59 Temple Place - Suite 330, Boston, MA +02111-1307, USA. */ + +/* The format of this file is + DEFTREESTRUCT(enumeration value, printable name). + Each enumeration value should correspond with a single member of union + tree_node. + These enumerator values are used in order to distinguish members of union + tree_node for garbage collection purposes, as well as specifying what structures + contain what other structures in the tree_contains_struct array. */ + +DEFTREESTRUCT(TS_COMMON, "common") +DEFTREESTRUCT(TS_INT_CST, "integer cst") +DEFTREESTRUCT(TS_REAL_CST, "real cst") +DEFTREESTRUCT(TS_VECTOR, "vector") +DEFTREESTRUCT(TS_STRING, "string") +DEFTREESTRUCT(TS_COMPLEX, "complex") +DEFTREESTRUCT(TS_IDENTIFIER, "indentifier") +DEFTREESTRUCT(TS_DECL_MINIMAL, "decl minimal") +DEFTREESTRUCT(TS_DECL_COMMON, "decl common") +DEFTREESTRUCT(TS_DECL_WRTL, "decl with RTL") +DEFTREESTRUCT(TS_DECL_NON_COMMON, "decl non-common") +DEFTREESTRUCT(TS_DECL_WITH_VIS, "decl with visibility") +DEFTREESTRUCT(TS_FIELD_DECL, "field decl") +DEFTREESTRUCT(TS_VAR_DECL, "var decl") +DEFTREESTRUCT(TS_PARM_DECL, "parm decl") +DEFTREESTRUCT(TS_LABEL_DECL, "label decl") +DEFTREESTRUCT(TS_RESULT_DECL, "result decl") +DEFTREESTRUCT(TS_CONST_DECL, "const decl") +DEFTREESTRUCT(TS_TYPE_DECL, "label decl") +DEFTREESTRUCT(TS_FUNCTION_DECL, "function decl") +DEFTREESTRUCT(TS_TYPE, "type") +DEFTREESTRUCT(TS_LIST, "list") +DEFTREESTRUCT(TS_VEC, "vec") +DEFTREESTRUCT(TS_EXP, "exp") +DEFTREESTRUCT(TS_SSA_NAME, "ssa name") +DEFTREESTRUCT(TS_PHI_NODE, "phi node") +DEFTREESTRUCT(TS_BLOCK, "block") +DEFTREESTRUCT(TS_BINFO, "binfo") +DEFTREESTRUCT(TS_STATEMENT_LIST, "statement list") +DEFTREESTRUCT(TS_VALUE_HANDLE, "value handle") |