summaryrefslogtreecommitdiff
path: root/gcc/function.c
diff options
context:
space:
mode:
authoraldyh <aldyh@138bc75d-0d04-0410-961f-82ee72b054a4>2006-05-05 19:57:38 +0000
committeraldyh <aldyh@138bc75d-0d04-0410-961f-82ee72b054a4>2006-05-05 19:57:38 +0000
commit35df6eb4cf95a3b0bcecbca6d63e9d6e8d8e8bd0 (patch)
tree31aff53c7f9388180b8f468318913668e9cb42be /gcc/function.c
parented672485f9897c7c1e2c9901f875c1b6690aa35c (diff)
downloadgcc-35df6eb4cf95a3b0bcecbca6d63e9d6e8d8e8bd0.tar.gz
PR/21391
* c-parser.c (c_parser_cast_expression): Only insert casts into hash table if pointer. * function.c (used_types_insert_helper): Rename from used_types_insert. (used_types_insert): Call used_types_insert_helper. * function.h (used_types_insert): Accept only one argument. * cp/typeck.c (build_static_cast_1): Save casted types in used types hash table. (build_reinterpret_cast_1): Same. * cp/rtti.c (build_dynamic_cast_1): Same. * testsuite/g++.dg/other/unused1.C: New. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@113561 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/function.c')
-rw-r--r--gcc/function.c25
1 files changed, 18 insertions, 7 deletions
diff --git a/gcc/function.c b/gcc/function.c
index cc50f50777d..bb6480118d6 100644
--- a/gcc/function.c
+++ b/gcc/function.c
@@ -5590,23 +5590,34 @@ rest_of_handle_check_leaf_regs (void)
return 0;
}
-/* Insert a type into the used types hash table. */
-void
-used_types_insert (tree t, struct function *func)
+/* Insert a TYPE into the used types hash table of CFUN. */
+static void
+used_types_insert_helper (tree type, struct function *func)
{
- if (t != NULL && func != NULL)
+ if (type != NULL && func != NULL)
{
void **slot;
if (func->used_types_hash == NULL)
func->used_types_hash = htab_create_ggc (37, htab_hash_pointer,
- htab_eq_pointer, NULL);
- slot = htab_find_slot (func->used_types_hash, t, INSERT);
+ htab_eq_pointer, NULL);
+ slot = htab_find_slot (func->used_types_hash, type, INSERT);
if (*slot == NULL)
- *slot = t;
+ *slot = type;
}
}
+/* Given a type, insert it into the used hash table in cfun. */
+void
+used_types_insert (tree t)
+{
+ while (POINTER_TYPE_P (t) || TREE_CODE (t) == ARRAY_TYPE)
+ t = TREE_TYPE (t);
+ t = TYPE_MAIN_VARIANT (t);
+ if (debug_info_level > DINFO_LEVEL_NONE)
+ used_types_insert_helper (t, cfun);
+}
+
struct tree_opt_pass pass_leaf_regs =
{
NULL, /* name */