summaryrefslogtreecommitdiff
path: root/gcc/cp
diff options
context:
space:
mode:
authornathan <nathan@138bc75d-0d04-0410-961f-82ee72b054a4>2003-09-18 17:07:53 +0000
committernathan <nathan@138bc75d-0d04-0410-961f-82ee72b054a4>2003-09-18 17:07:53 +0000
commit0767cba934e92d31349601c9e58281878096a310 (patch)
treee282a8b31bbf685e2f19352bd0b60a68eddc7257 /gcc/cp
parent0deb47ed60e5ed86f389d3d6fe5b2afdceb897cb (diff)
downloadgcc-0767cba934e92d31349601c9e58281878096a310.tar.gz
cp:
PR c++/9848 * optimize.c (maybe_clone_body): Don't set MARK_USED on parameters here. * semantics.c (expand_body): Set it here on the remaining clones. testsuite: PR c++/9848 * g++.dg/warn/Wunused-4.C: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@71528 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cp')
-rw-r--r--gcc/cp/ChangeLog7
-rw-r--r--gcc/cp/optimize.c12
-rw-r--r--gcc/cp/semantics.c20
3 files changed, 30 insertions, 9 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 1d3c8b207e0..ad41de2c00e 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,10 @@
+2003-09-18 Nathan Sidwell <nathan@codesourcery.com>
+
+ PR c++/9848
+ * optimize.c (maybe_clone_body): Don't set MARK_USED on parameters
+ here.
+ * semantics.c (expand_body): Set it here on the remaining clones.
+
2003-09-18 Roger Sayle <roger@eyesopen.com>
* lex.c (init_operators): Remove operator_name_info for FFS_EXPR.
diff --git a/gcc/cp/optimize.c b/gcc/cp/optimize.c
index 3204311ea7d..2b7df6c5244 100644
--- a/gcc/cp/optimize.c
+++ b/gcc/cp/optimize.c
@@ -120,7 +120,6 @@ bool
maybe_clone_body (tree fn)
{
tree clone;
- bool first = true;
/* We only clone constructors and destructors. */
if (!DECL_MAYBE_IN_CHARGE_CONSTRUCTOR_P (fn)
@@ -139,7 +138,7 @@ maybe_clone_body (tree fn)
list. */
for (clone = TREE_CHAIN (fn);
clone && DECL_CLONED_FUNCTION_P (clone);
- clone = TREE_CHAIN (clone), first = false)
+ clone = TREE_CHAIN (clone))
{
tree parm;
tree clone_parm;
@@ -175,13 +174,8 @@ maybe_clone_body (tree fn)
clone_parm = TREE_CHAIN (clone_parm);
for (; parm;
parm = TREE_CHAIN (parm), clone_parm = TREE_CHAIN (clone_parm))
- {
- /* Update this parameter. */
- update_cloned_parm (parm, clone_parm);
- /* We should only give unused information for one clone. */
- if (!first)
- TREE_USED (clone_parm) = 1;
- }
+ /* Update this parameter. */
+ update_cloned_parm (parm, clone_parm);
/* Start processing the function. */
push_to_top_level ();
diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index 37dca0a6a57..ef42579f349 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -2887,6 +2887,26 @@ expand_body (tree fn)
static duration objects. */
if (DECL_STATIC_DESTRUCTOR (fn))
static_dtors = tree_cons (NULL_TREE, fn, static_dtors);
+
+ if (DECL_CLONED_FUNCTION_P (fn))
+ {
+ /* If this is a clone, go through the other clones now and mark
+ their parameters used. We have to do that here, as we don't
+ know whether any particular clone will be expanded, and
+ therefore cannot pick one arbitrarily. */
+ tree probe;
+
+ for (probe = TREE_CHAIN (DECL_CLONED_FUNCTION (fn));
+ probe && DECL_CLONED_FUNCTION_P (probe);
+ probe = TREE_CHAIN (probe))
+ {
+ tree parms;
+
+ for (parms = DECL_ARGUMENTS (probe);
+ parms; parms = TREE_CHAIN (parms))
+ TREE_USED (parms) = 1;
+ }
+ }
}
/* Generate RTL for FN. */