diff options
author | Richard Henderson <rth@redhat.com> | 2003-10-05 12:07:47 -0700 |
---|---|---|
committer | Richard Henderson <rth@gcc.gnu.org> | 2003-10-05 12:07:47 -0700 |
commit | 3c2a7a6a2639845787d3b68b7eceb82bb17bc54d (patch) | |
tree | 34e4f389e33a00021eeccf202312f4f5e5f221cf /gcc/tree.c | |
parent | a2b172fb9c199753770b05e27af9d242706f8c26 (diff) | |
download | gcc-3c2a7a6a2639845787d3b68b7eceb82bb17bc54d.zip gcc-3c2a7a6a2639845787d3b68b7eceb82bb17bc54d.tar.gz gcc-3c2a7a6a2639845787d3b68b7eceb82bb17bc54d.tar.bz2 |
tree-inline.c (remap_type): New.
* tree-inline.c (remap_type): New.
(remap_decl): Use it. Remap DECL_SIZE*.
(copy_body_r): Use it.
(walk_tree): Walk TREE_TYPE too.
(copy_tree_r): Don't walk subtrees of types.
* tree.c (variably_modified_type_p): Restructure. Consider integer
types with non-const bounds variably modified.
From-SVN: r72114
Diffstat (limited to 'gcc/tree.c')
-rw-r--r-- | gcc/tree.c | 67 |
1 files changed, 40 insertions, 27 deletions
@@ -4273,6 +4273,8 @@ int_fits_type_p (tree c, tree type) bool variably_modified_type_p (tree type) { + tree t; + if (type == error_mark_node) return false; @@ -4281,39 +4283,50 @@ variably_modified_type_p (tree type) 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) + t = TYPE_SIZE (type); + if (t && t != error_mark_node && TREE_CODE (t) != 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; + switch (TREE_CODE (type)) + { + case POINTER_TYPE: + case REFERENCE_TYPE: + case ARRAY_TYPE: + /* If TYPE is a pointer or reference, it is variably modified if + the type pointed to is variably modified. Similarly for arrays; + note that VLAs are handled by the TYPE_SIZE check above. */ + 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 already been checked - above.) */ - if (TREE_CODE (type) == ARRAY_TYPE - && variably_modified_type_p (TREE_TYPE (type))) - return true; + case FUNCTION_TYPE: + case METHOD_TYPE: + /* If TYPE is a function type, it is variably modified if any of the + parameters or the return type are variably modified. */ + { + tree parm; - /* 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; + } + break; - if (variably_modified_type_p (TREE_TYPE (type))) + case INTEGER_TYPE: + /* Scalar types are variably modified if their end points + aren't constant. */ + t = TYPE_MIN_VALUE (type); + if (t && t != error_mark_node && TREE_CODE (t) != INTEGER_CST) 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; + t = TYPE_MAX_VALUE (type); + if (t && t != error_mark_node && TREE_CODE (t) != INTEGER_CST) + return true; + return false; + + default: + break; } /* The current language may have other cases to check, but in general, |