aboutsummaryrefslogtreecommitdiff
path: root/gcc/function.c
diff options
context:
space:
mode:
authorAldy Hernandez <aldyh@redhat.com>2006-05-05 19:57:38 +0000
committerAldy Hernandez <aldyh@gcc.gnu.org>2006-05-05 19:57:38 +0000
commit8d8d1a280135e6530e1d2eb42c5ff8b91a8f570c (patch)
tree31aff53c7f9388180b8f468318913668e9cb42be /gcc/function.c
parentb207220873a208cab0b8fea85bf5be77bcd15914 (diff)
downloadgcc-8d8d1a280135e6530e1d2eb42c5ff8b91a8f570c.zip
gcc-8d8d1a280135e6530e1d2eb42c5ff8b91a8f570c.tar.gz
gcc-8d8d1a280135e6530e1d2eb42c5ff8b91a8f570c.tar.bz2
c-parser.c (c_parser_cast_expression): Only insert casts into hash table if pointer.
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. From-SVN: r113561
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 cc50f50..bb64801 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 */