diff options
author | Zack Weinberg <zack@gcc.gnu.org> | 2002-10-23 17:13:18 +0000 |
---|---|---|
committer | Zack Weinberg <zack@gcc.gnu.org> | 2002-10-23 17:13:18 +0000 |
commit | 8bcefb43ccfaf402c35312dd06c234e2ec975656 (patch) | |
tree | 8f64273fe292a54b0d5d5c23aa635d97a7aba7d7 /gcc | |
parent | 09c68baa38cc66400b8bdb86137d8c6e1b0e663e (diff) | |
download | gcc-8bcefb43ccfaf402c35312dd06c234e2ec975656.zip gcc-8bcefb43ccfaf402c35312dd06c234e2ec975656.tar.gz gcc-8bcefb43ccfaf402c35312dd06c234e2ec975656.tar.bz2 |
langhooks.h (struct lang_hooks_for_tree_inlining): Add var_mod_type_p.
* langhooks.h (struct lang_hooks_for_tree_inlining): Add
var_mod_type_p.
* langhooks-def.h: Default for tree_inlining.var_mod_type_p is
hook_tree_bool_false.
* tree.c (variably_modified_type_p): Moved here from
cp/tree.c. Use lang_hooks.tree_inlining.var_mod_type_p for
language-specific cases. Due to this, must weaken some 'if
and only if' checks to merely 'if'.
* tree.h: Prototype variably_modified_type_p.
* tree-inline.c (walk_tree): #undef WALK_SUBTREE_TAIL at end.
cp:
* cp-lang.c (cp_var_mod_type_p): New: C++ hook for
variably_modified_type_p.
* cp-tree.h: Remove prototype of variably_modified_type_p.
* tree.c (variably_modified_type_p): Remove; now implemented
in language-independent code.
From-SVN: r58460
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 27 | ||||
-rw-r--r-- | gcc/cp/ChangeLog | 10 | ||||
-rw-r--r-- | gcc/cp/cp-lang.c | 21 | ||||
-rw-r--r-- | gcc/cp/cp-tree.h | 1 | ||||
-rw-r--r-- | gcc/cp/tree.c | 66 | ||||
-rw-r--r-- | gcc/langhooks-def.h | 3 | ||||
-rw-r--r-- | gcc/langhooks.h | 1 | ||||
-rw-r--r-- | gcc/tree-inline.c | 1 | ||||
-rw-r--r-- | gcc/tree.c | 59 | ||||
-rw-r--r-- | gcc/tree.h | 1 |
10 files changed, 116 insertions, 74 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index e7c4e9a..1141063 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,18 @@ +2002-10-23 Zack Weinberg <zack@codesourcery.com> + + * langhooks.h (struct lang_hooks_for_tree_inlining): Add + var_mod_type_p. + * langhooks-def.h: Default for tree_inlining.var_mod_type_p is + hook_tree_bool_false. + + * tree.c (variably_modified_type_p): Moved here from + cp/tree.c. Use lang_hooks.tree_inlining.var_mod_type_p for + language-specific cases. Due to this, must weaken some 'if + and only if' checks to merely 'if'. + * tree.h: Prototype variably_modified_type_p. + + * tree-inline.c (walk_tree): #undef WALK_SUBTREE_TAIL at end. + 2002-10-23 Ulrich Weigand <uweigand@de.ibm.com> * config/s390/linux.h (CC1_SPEC, CC1PLUS_SPEC): Remove. @@ -9,7 +24,7 @@ ("*movdi_lhi", "*movdi_lli", "*movdi_larl"): Likewise. ("movsi", "*movsi_lhi", "*movsi_lli"): Likewise. (movdi_31, movdf_31 splitters): Likewise. - + * config/s390/s390.h (IEEE_FLOAT): Remove. (TARGET_FLOAT_FORMAT): Define in terms of TARGET_IEEE_FLOAT. (INT_REGNO_P): Rename to ... @@ -33,7 +48,7 @@ 2002-10-23 Ulrich Weigand <uweigand@de.ibm.com> - * libgcc2.c (__udiv_w_sdiv): Use attribute ((always_inline)) when + * libgcc2.c (__udiv_w_sdiv): Use attribute ((always_inline)) when inlining it into other libgcc2 routines. (__udivmoddi4): Likewise. @@ -100,7 +115,7 @@ Wed Oct 23 01:52:36 CEST 2002 Jan Hubicka <jh@suse.cz> * config/rs6000/xcoff.h (ASM_DECLARE_FUNCTION_NAME): Don't call xcoffout_declare_function when using rs6000_output_mi_thunk. - * config/s390/s390.c (s390_output_mi_thunk): Rename from + * config/s390/s390.c (s390_output_mi_thunk): Rename from s390_output_mi_vcall_thunk. (TARGET_ASM_OUTPUT_MI_THUNK): Remove. (TARGET_ASM_CAN_OUTPUT_MI_THUNK): New. @@ -230,7 +245,7 @@ Tue Oct 22 00:04:20 CEST 2002 Jan Hubicka <jh@suse.cz> 2002-10-21 Dale Johannesen <dalej@apple.com> - * config/rs6000/rs6000.c (rs6000_reverse_condition): Handle + * config/rs6000/rs6000.c (rs6000_reverse_condition): Handle unsafe math reversals correctly for RTL generation. (output_cbranch): Replace rs6000_reverse_condition call by its former definition. @@ -396,7 +411,7 @@ Tue Oct 22 00:04:20 CEST 2002 Jan Hubicka <jh@suse.cz> -fsched-verbose=n, -fno-branch-count-reg and -fbounds-check. 2002-10-19 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> - Mark Mitchell <mark@codesourcery.com> + Mark Mitchell <mark@codesourcery.com> * alpha-protos.h (alpha_output_mi_thunk_osf): Update signature to match target.h. @@ -466,7 +481,7 @@ Sun Oct 20 00:31:31 CEST 2002 Jan Hubicka <jh@suse.cz> 2002-10-19 Sebastian Pop <s.pop@laposte.net> * dependence.c : Removed. - * Makefile.in : Remove dependence.o. + * Makefile.in : Remove dependence.o. Sat Oct 19 10:46:52 CEST 2002 Jan Hubicka <jh@suse.cz> diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 2529697..d6f7be71 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,11 @@ +2002-10-23 Zack Weinberg <zack@codesourcery.com> + + * cp-lang.c (cp_var_mod_type_p): New: C++ hook for + variably_modified_type_p. + * cp-tree.h: Remove prototype of variably_modified_type_p. + * tree.c (variably_modified_type_p): Remove; now implemented + in language-independent code. + 2002-10-22 Mark Mitchell <mark@codesourcery.com> PR c++/6579 @@ -37,7 +45,7 @@ * method.c (use_thunk): Compute the vcall index as a HOST_WIDE_INT. * optimize.c (optimize_function): Replace ASM_OUTPUT_MI_THUNK with TARGET_ASM_OUTPUT_MI_THUNK in comments. - + 2002-10-18 Zack Weinberg <zack@codesourcery.com> * decl.c (start_decl): Point users of the old initialized- diff --git a/gcc/cp/cp-lang.c b/gcc/cp/cp-lang.c index 51239a5..d89fb63 100644 --- a/gcc/cp/cp-lang.c +++ b/gcc/cp/cp-lang.c @@ -32,6 +32,7 @@ static HOST_WIDE_INT cxx_get_alias_set PARAMS ((tree)); static bool ok_to_generate_alias_set_for_type PARAMS ((tree)); static bool cxx_warn_unused_global_decl PARAMS ((tree)); static tree cp_expr_size PARAMS ((tree)); +static bool cp_var_mod_type_p PARAMS ((tree)); #undef LANG_HOOKS_NAME #define LANG_HOOKS_NAME "GNU C++" @@ -126,6 +127,8 @@ static tree cp_expr_size PARAMS ((tree)); cp_convert_parm_for_inlining #undef LANG_HOOKS_TREE_INLINING_ANON_AGGR_TYPE_P #define LANG_HOOKS_TREE_INLINING_ANON_AGGR_TYPE_P anon_aggr_type_p +#undef LANG_HOOKS_TREE_INLINING_VAR_MOD_TYPE_P +#define LANG_HOOKS_TREE_INLINING_VAR_MOD_TYPE_P cp_var_mod_type_p #undef LANG_HOOKS_TREE_INLINING_START_INLINING #define LANG_HOOKS_TREE_INLINING_START_INLINING cp_start_inlining #undef LANG_HOOKS_TREE_INLINING_END_INLINING @@ -310,3 +313,21 @@ cp_expr_size (exp) /* Use the default code. */ return lhd_expr_size (exp); } + +/* Returns true if T is a variably modified type, in the sense of C99. + This routine needs only check cases that cannot be handled by the + language-independent logic in tree-inline.c. */ + +static bool +cp_var_mod_type_p (tree type) +{ + /* If TYPE is a pointer-to-member, it is variably modified if either + the class or the member are variably modified. */ + if (TYPE_PTRMEM_P (type) || TYPE_PTRMEMFUNC_P (type)) + return (variably_modified_type_p (TYPE_PTRMEM_CLASS_TYPE (type)) + || variably_modified_type_p (TYPE_PTRMEM_POINTED_TO_TYPE (type))); + + /* All other types are not variably modified. */ + return false; +} + diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index 06e80b5..364b545 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -4191,7 +4191,6 @@ extern tree cxx_unsave_expr_now PARAMS ((tree)); extern tree cxx_maybe_build_cleanup PARAMS ((tree)); extern void init_tree PARAMS ((void)); extern int pod_type_p PARAMS ((tree)); -extern bool variably_modified_type_p (tree); extern int zero_init_p PARAMS ((tree)); extern tree canonical_type_variant PARAMS ((tree)); extern void unshare_base_binfos PARAMS ((tree)); diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index ddc1ce1..4b1142b 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -1958,72 +1958,6 @@ pod_type_p (t) return 1; } -/* Returns true if T is a variably modified type, in the sense of - C99. - - In C99, a struct type is never variably modified because a VLA may - not appear as a structure member. However, in GNU C code like: - - struct S { int i[f()]; }; - - is valid. Even though GNU C++ does not allow that, this function - may sometimes be used in the C front end, so it treats any type - with variable size in the same way that C99 treats VLAs. - - In particular, a variably modified type is one that involves a type - with variable size. */ - -bool -variably_modified_type_p (tree type) -{ - /* If TYPE itself has variable size, it is variably modified. - - We do not yet have a representation of the C99 '[*]' syntax. - When a representation is chosen, this function should be modified - to test for that case as well. */ - if (TYPE_SIZE (type) - && TYPE_SIZE (type) != error_mark_node - && TREE_CODE (TYPE_SIZE (type)) != INTEGER_CST) - return true; - - /* If TYPE is a pointer or reference, it is variably modified if and - only if the type pointed to is variably modified. */ - if (TYPE_PTR_P (type) - || TREE_CODE (type) == REFERENCE_TYPE) - return variably_modified_type_p (TREE_TYPE (type)); - - /* If TYPE is an array, it is variably modified if the array - elements are. (Note that the VLA case has alredy been checked - above). */ - if (TREE_CODE (type) == ARRAY_TYPE) - return variably_modified_type_p (TREE_TYPE (type)); - - /* If TYPE is a pointer-to-member, it is variably modified if either - the class or the member are variably modified. */ - if (TYPE_PTRMEM_P (type) || TYPE_PTRMEMFUNC_P (type)) - return (variably_modified_type_p (TYPE_PTRMEM_CLASS_TYPE (type)) - || variably_modified_type_p (TYPE_PTRMEM_POINTED_TO_TYPE (type))); - - /* If TYPE Is a function type, it is variably modified if any of the - parameters or the return type are variably modified. */ - if (TREE_CODE (type) == FUNCTION_TYPE - || TREE_CODE (type) == METHOD_TYPE) - { - tree parm; - - if (variably_modified_type_p (TREE_TYPE (type))) - return true; - for (parm = TYPE_ARG_TYPES (type); - parm && parm != void_list_node; - parm = TREE_CHAIN (parm)) - if (variably_modified_type_p (TREE_VALUE (parm))) - return true; - } - - /* All other types are not variably modified. */ - return false; -} - /* Returns 1 iff zero initialization of type T means actually storing zeros in it. */ diff --git a/gcc/langhooks-def.h b/gcc/langhooks-def.h index 0b05d14..8444ef4 100644 --- a/gcc/langhooks-def.h +++ b/gcc/langhooks-def.h @@ -140,6 +140,8 @@ tree lhd_tree_inlining_convert_parm_for_inlining PARAMS ((tree, tree, tree)); lhd_tree_inlining_copy_res_decl_for_inlining #define LANG_HOOKS_TREE_INLINING_ANON_AGGR_TYPE_P \ lhd_tree_inlining_anon_aggr_type_p +#define LANG_HOOKS_TREE_INLINING_VAR_MOD_TYPE_P \ + hook_tree_bool_false #define LANG_HOOKS_TREE_INLINING_START_INLINING \ lhd_tree_inlining_start_inlining #define LANG_HOOKS_TREE_INLINING_END_INLINING \ @@ -156,6 +158,7 @@ tree lhd_tree_inlining_convert_parm_for_inlining PARAMS ((tree, tree, tree)); LANG_HOOKS_TREE_INLINING_AUTO_VAR_IN_FN_P, \ LANG_HOOKS_TREE_INLINING_COPY_RES_DECL_FOR_INLINING, \ LANG_HOOKS_TREE_INLINING_ANON_AGGR_TYPE_P, \ + LANG_HOOKS_TREE_INLINING_VAR_MOD_TYPE_P, \ LANG_HOOKS_TREE_INLINING_START_INLINING, \ LANG_HOOKS_TREE_INLINING_END_INLINING, \ LANG_HOOKS_TREE_INLINING_CONVERT_PARM_FOR_INLINING \ diff --git a/gcc/langhooks.h b/gcc/langhooks.h index 0518afe..09e5971 100644 --- a/gcc/langhooks.h +++ b/gcc/langhooks.h @@ -50,6 +50,7 @@ struct lang_hooks_for_tree_inlining void *, int *, void *)); int (*anon_aggr_type_p) PARAMS ((union tree_node *)); + bool (*var_mod_type_p) PARAMS ((union tree_node *)); int (*start_inlining) PARAMS ((union tree_node *)); void (*end_inlining) PARAMS ((union tree_node *)); union tree_node *(*convert_parm_for_inlining) PARAMS ((union tree_node *, diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c index f0194ad..505f0a5 100644 --- a/gcc/tree-inline.c +++ b/gcc/tree-inline.c @@ -1647,6 +1647,7 @@ walk_tree (tp, func, data, htab_) return NULL_TREE; #undef WALK_SUBTREE +#undef WALK_SUBTREE_TAIL } /* Like walk_tree, but does not walk duplicate nodes more than @@ -4151,6 +4151,65 @@ int_fits_type_p (c, type) } } +/* Returns true if T is, contains, or refers to a type with variable + size. This concept is more general than that of C99 'variably + modified types': in C99, a struct type is never variably modified + because a VLA may not appear as a structure member. However, in + GNU C code like: + + struct S { int i[f()]; }; + + is valid, and other languages may define similar constructs. */ + +bool +variably_modified_type_p (type) + tree type; +{ + /* If TYPE itself has variable size, it is variably modified. + + We do not yet have a representation of the C99 '[*]' syntax. + When a representation is chosen, this function should be modified + to test for that case as well. */ + if (TYPE_SIZE (type) + && TYPE_SIZE (type) != error_mark_node + && TREE_CODE (TYPE_SIZE (type)) != INTEGER_CST) + return true; + + /* If TYPE is a pointer or reference, it is variably modified if + the type pointed to is variably modified. */ + if ((TREE_CODE (type) == POINTER_TYPE + || TREE_CODE (type) == REFERENCE_TYPE) + && variably_modified_type_p (TREE_TYPE (type))) + return true; + + /* If TYPE is an array, it is variably modified if the array + elements are. (Note that the VLA case has already been checked + above.) */ + if (TREE_CODE (type) == ARRAY_TYPE + && variably_modified_type_p (TREE_TYPE (type))) + return true; + + /* If TYPE is a function type, it is variably modified if any of the + parameters or the return type are variably modified. */ + if (TREE_CODE (type) == FUNCTION_TYPE + || TREE_CODE (type) == METHOD_TYPE) + { + tree parm; + + if (variably_modified_type_p (TREE_TYPE (type))) + return true; + for (parm = TYPE_ARG_TYPES (type); + parm && parm != void_list_node; + parm = TREE_CHAIN (parm)) + if (variably_modified_type_p (TREE_VALUE (parm))) + return true; + } + + /* The current language may have other cases to check, but in general, + all other types are not variably modified. */ + return (*lang_hooks.tree_inlining.var_mod_type_p) (type); +} + /* Given a DECL or TYPE, return the scope in which it was declared, or NULL_TREE if there is no containing scope. */ @@ -2909,6 +2909,7 @@ struct obstack; /* In tree.c */ extern int really_constant_p PARAMS ((tree)); extern int int_fits_type_p PARAMS ((tree, tree)); +extern bool variably_modified_type_p PARAMS ((tree)); extern int tree_log2 PARAMS ((tree)); extern int tree_floor_log2 PARAMS ((tree)); extern int simple_cst_equal PARAMS ((tree, tree)); |