aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/rtti.c
diff options
context:
space:
mode:
authorNathan Sidwell <nathan@codesourcery.com>2003-09-05 08:24:28 +0000
committerNathan Sidwell <nathan@gcc.gnu.org>2003-09-05 08:24:28 +0000
commit8e1daa341261864912c3b19c87c78babd4a80edf (patch)
treeed79054903625cbc8d96d97ada515039d44845bc /gcc/cp/rtti.c
parent7976070c7125db206c88126464a99a18c3886e09 (diff)
downloadgcc-8e1daa341261864912c3b19c87c78babd4a80edf.zip
gcc-8e1daa341261864912c3b19c87c78babd4a80edf.tar.gz
gcc-8e1daa341261864912c3b19c87c78babd4a80edf.tar.bz2
re PR c++/12037 (Spurious "statement has no effect" in templates)
cp: PR c++/12037 * cp-tree.h (COMPOUND_EXPR_OVERLOADED): New. (build_min_non_dep): Declare. * tree.c (build_min): Propagate TREE_SIDE_EFFECTS. (build_min_non_dep): New. * cvt.c (convert_to_void): Don't explicitly copy TREE_SIDE_EFFECTS, TREE_NO_UNUSED_WARNING. * call.c (build_new_method_call): Use build_min_non_dep. * decl2.c (grok_array_decl): Likewise. (build_offset_ref_call_from_tree): Likewise. * typeck.c (finish_class_member_access_expr, build_x_indirect_ref, build_x_binary_op, build_x_unary_op, build_x_conditional_expr, build_x_compound_expr): Likewise. (build_static_cast, build_reinterpret_cast, build_const_cast): Propagate TREE_SIDE_EFFECTS inside a template. * typeck2.c (build_x_arrow): Use build_min_non_dep. (build_functional_cast): Propagate TREE_SIDE_EFFECTS inside a template. * rtti.c (build_dynamic_cast_1): Set DECL_IS_PURE. (build_dynamic_cast): Set TREE_SIDE_EFFECTS. * pt.c (build_non_dependent_expr): Check COMPOUND_EXPR_OVERLOADED. testsuite: PR c++/12037 * g++.dg/warn/noeffect4.C: New test. From-SVN: r71108
Diffstat (limited to 'gcc/cp/rtti.c')
-rw-r--r--gcc/cp/rtti.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/gcc/cp/rtti.c b/gcc/cp/rtti.c
index 5e3437f..32d318d 100644
--- a/gcc/cp/rtti.c
+++ b/gcc/cp/rtti.c
@@ -652,6 +652,7 @@ build_dynamic_cast_1 (tree type, tree expr)
(NULL_TREE, ptrdiff_type_node, void_list_node))));
tmp = build_function_type (ptr_type_node, tmp);
dcast_fn = build_library_fn_ptr (name, tmp);
+ DECL_IS_PURE (dcast_fn) = 1;
pop_nested_namespace (ns);
dynamic_cast_node = dcast_fn;
}
@@ -686,7 +687,12 @@ build_dynamic_cast (tree type, tree expr)
return error_mark_node;
if (processing_template_decl)
- return build_min (DYNAMIC_CAST_EXPR, type, expr);
+ {
+ expr = build_min (DYNAMIC_CAST_EXPR, type, expr);
+ TREE_SIDE_EFFECTS (expr) = 1;
+
+ return expr;
+ }
return convert_from_reference (build_dynamic_cast_1 (type, expr));
}