aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathan Sidwell <nathan@codesourcery.com>2001-04-27 12:47:22 +0000
committerNathan Sidwell <nathan@gcc.gnu.org>2001-04-27 12:47:22 +0000
commit02a1a68c6acafc9d9a1af97a9eefebd9af69d477 (patch)
tree3ecd1e3881ee02b7bc81981fbffbe159cf82615e
parent5f6eeeb3625bd5121465d8a50c89f47b25af0a69 (diff)
downloadgcc-02a1a68c6acafc9d9a1af97a9eefebd9af69d477.zip
gcc-02a1a68c6acafc9d9a1af97a9eefebd9af69d477.tar.gz
gcc-02a1a68c6acafc9d9a1af97a9eefebd9af69d477.tar.bz2
optimize.c (maybe_clone_body): Copy parameter names and locations.
cp: * optimize.c (maybe_clone_body): Copy parameter names and locations. testsuite: * g++.old-deja/g++.other/warn7.C: New test. From-SVN: r41627
-rw-r--r--gcc/cp/ChangeLog4
-rw-r--r--gcc/cp/optimize.c28
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/g++.old-deja/g++.other/warn7.C45
4 files changed, 79 insertions, 2 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 7dc59bf..7e49e69 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,9 @@
2001-04-27 Nathan Sidwell <nathan@codesourcery.com>
+ * optimize.c (maybe_clone_body): Copy parameter names and locations.
+
+2001-04-27 Nathan Sidwell <nathan@codesourcery.com>
+
* cp-tree.h (adjust_clone_args): Prototype new function.
* class.c (adjust_clone_args): New function.
* decl.c (start_function): Call it for in charge ctors.
diff --git a/gcc/cp/optimize.c b/gcc/cp/optimize.c
index 541bdf9..ae5a1ff 100644
--- a/gcc/cp/optimize.c
+++ b/gcc/cp/optimize.c
@@ -1019,6 +1019,7 @@ maybe_clone_body (fn)
{
inline_data id;
tree clone;
+ int first = 1;
/* We only clone constructors and destructors. */
if (!DECL_MAYBE_IN_CHARGE_CONSTRUCTOR_P (fn)
@@ -1032,7 +1033,7 @@ maybe_clone_body (fn)
list. */
for (clone = TREE_CHAIN (fn);
clone && DECL_CLONED_FUNCTION_P (clone);
- clone = TREE_CHAIN (clone))
+ clone = TREE_CHAIN (clone), first = 0)
{
tree parm;
tree clone_parm;
@@ -1053,6 +1054,30 @@ maybe_clone_body (fn)
DECL_NOT_REALLY_EXTERN (clone) = DECL_NOT_REALLY_EXTERN (fn);
TREE_PUBLIC (clone) = TREE_PUBLIC (fn);
+ /* Adjust the parameter names and locations. */
+ parm = DECL_ARGUMENTS (fn);
+ clone_parm = DECL_ARGUMENTS (clone);
+ if (DECL_HAS_IN_CHARGE_PARM_P (fn))
+ parm = TREE_CHAIN (parm);
+ if (DECL_HAS_VTT_PARM_P (fn))
+ parm = TREE_CHAIN (parm);
+ if (DECL_HAS_VTT_PARM_P (clone))
+ clone_parm = TREE_CHAIN (clone_parm);
+ for (; parm;
+ parm = TREE_CHAIN (parm), clone_parm = TREE_CHAIN (clone_parm))
+ {
+ DECL_ABSTRACT_ORIGIN (clone_parm) = parm;
+
+ /* The name may have changed from the declaration. */
+ DECL_NAME (clone_parm) = DECL_NAME (parm);
+ DECL_SOURCE_FILE (clone_parm) = DECL_SOURCE_FILE (parm);
+ DECL_SOURCE_LINE (clone_parm) = DECL_SOURCE_LINE (parm);
+
+ /* We should only give unused information for one clone. */
+ if (!first)
+ TREE_USED (clone_parm) = 1;
+ }
+
/* Start processing the function. */
push_to_top_level ();
start_function (NULL_TREE, clone, NULL_TREE, SF_PRE_PARSED);
@@ -1115,7 +1140,6 @@ maybe_clone_body (fn)
function. */
else
{
- DECL_ABSTRACT_ORIGIN (clone_parm) = parm;
splay_tree_insert (id.decl_map,
(splay_tree_key) parm,
(splay_tree_value) clone_parm);
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 1f7bb78..d04c26c 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,9 @@
2001-04-27 Nathan Sidwell <nathan@codesourcery.com>
+ * g++.old-deja/g++.other/warn7.C: New test.
+
+2001-04-27 Nathan Sidwell <nathan@codesourcery.com>
+
* g++.old-deja/g++.other/defarg9.C: New test.
2001-04-26 Toon Moene <toon@moene.indiv.nluug.nl>
diff --git a/gcc/testsuite/g++.old-deja/g++.other/warn7.C b/gcc/testsuite/g++.old-deja/g++.other/warn7.C
new file mode 100644
index 0000000..a27756a
--- /dev/null
+++ b/gcc/testsuite/g++.old-deja/g++.other/warn7.C
@@ -0,0 +1,45 @@
+// Build don't link:
+// Special g++ Options: -W -Wall
+//
+// Copyright (C) 2001 Free Software Foundation, Inc.
+// Contributed by Nathan Sidwell 26 April 2001 <nathan@codesourcery.com>
+
+// Bug 2356. Unused parameter information introduced in a ctor
+// definition was not propagated to clones, leading to missed or
+// unwarranted unused parameter warnings, possibly given twice.
+
+struct X
+{
+ X(int i);
+ void foo (int i);
+
+};
+void foo (int i);
+
+X::X(int)
+{
+}
+void X::foo (int)
+{
+}
+void foo (int)
+{
+}
+
+struct Y
+{
+ Y(int);
+ void bar (int);
+
+};
+void bar (int);
+
+Y::Y(int i)
+{ // WARNING - unused parameter
+}
+void Y::bar (int i)
+{ // WARNING - unused parameter
+}
+void bar (int i)
+{ // WARNING - unused parameter
+}