From 8d8d1a280135e6530e1d2eb42c5ff8b91a8f570c Mon Sep 17 00:00:00 2001 From: Aldy Hernandez Date: Fri, 5 May 2006 19:57:38 +0000 Subject: 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 --- gcc/cp/ChangeLog | 8 ++++++++ gcc/cp/rtti.c | 3 +++ gcc/cp/typeck.c | 9 +++++++++ 3 files changed, 20 insertions(+) (limited to 'gcc/cp') diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index d4a01fc..f423f4f 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,11 @@ +2006-05-03 Aldy Hernandez + + PR/21391 + * typeck.c (build_static_cast_1): Save casted types in used types + hash table. + (build_reinterpret_cast_1): Same. + * rtti.c (build_dynamic_cast_1): Same. + 2006-05-04 Jakub Jelinek PR c++/27359 diff --git a/gcc/cp/rtti.c b/gcc/cp/rtti.c index 5c6d38d..6242e44 100644 --- a/gcc/cp/rtti.c +++ b/gcc/cp/rtti.c @@ -464,6 +464,9 @@ build_dynamic_cast_1 (tree type, tree expr) tree old_expr = expr; const char *errstr = NULL; + /* Save casted types in the function's used types hash table. */ + used_types_insert (type); + /* T shall be a pointer or reference to a complete class type, or `pointer to cv void''. */ switch (tc) diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index 394a4ec..78e3a2b 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -4759,6 +4759,9 @@ build_static_cast_1 (tree type, tree expr, bool c_cast_p, intype = TREE_TYPE (expr); + /* Save casted types in the function's used types hash table. */ + used_types_insert (type); + /* Determine what to do when casting away constness. */ if (c_cast_p) { @@ -5047,6 +5050,9 @@ build_reinterpret_cast_1 (tree type, tree expr, bool c_cast_p, intype = TREE_TYPE (expr); + /* Save casted types in the function's used types hash table. */ + used_types_insert (type); + /* [expr.reinterpret.cast] An lvalue expression of type T1 can be cast to the type "reference to T2" if an expression of type "pointer to T1" can be @@ -5242,6 +5248,9 @@ build_const_cast_1 (tree dst_type, tree expr, bool complain, return error_mark_node; } + /* Save casted types in the function's used types hash table. */ + used_types_insert (dst_type); + src_type = TREE_TYPE (expr); /* Expressions do not really have reference types. */ if (TREE_CODE (src_type) == REFERENCE_TYPE) -- cgit v1.1