aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorNathan Sidwell <nathan@codesourcery.com>2001-05-20 13:41:34 +0000
committerNathan Sidwell <nathan@gcc.gnu.org>2001-05-20 13:41:34 +0000
commitd30a825a20a3ff56fe44f5adaf5d5c6153785cac (patch)
treee3de0e3eaa9d99d38ab4bcb7dfec4cf41c3a4c1c /gcc
parent3b82c249189ff6349ca7d8407258cb9745fd3b17 (diff)
downloadgcc-d30a825a20a3ff56fe44f5adaf5d5c6153785cac.zip
gcc-d30a825a20a3ff56fe44f5adaf5d5c6153785cac.tar.gz
gcc-d30a825a20a3ff56fe44f5adaf5d5c6153785cac.tar.bz2
re PR c++/2781 (bad code generated for reference call with -O2 (regression from 2.95))
cp: PR c++/2781 * optimize.c (update_cloned_parm): Copy addressability and other flags. testsuite: * g++.old-deja/g++.other/optimize1.C: New test. From-SVN: r42344
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/optimize.c9
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/g++.old-deja/g++.other/optimize1.C70
4 files changed, 88 insertions, 1 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 42d2ae1..a05a3ac 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,9 @@
+2001-05-20 Nathan Sidwell <nathan@codesourcery.com>
+
+ PR c++/2781
+ * optimize.c (update_cloned_parm): Copy addressability and other
+ flags.
+
2001-05-20 Kriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net>
* pt.c (determine_specialization): Ignore artificial functions.
diff --git a/gcc/cp/optimize.c b/gcc/cp/optimize.c
index 5b02987..b6b03b9 100644
--- a/gcc/cp/optimize.c
+++ b/gcc/cp/optimize.c
@@ -1021,12 +1021,19 @@ update_cloned_parm (parm, cloned_parm)
tree cloned_parm;
{
DECL_ABSTRACT_ORIGIN (cloned_parm) = parm;
+
+ /* We may have taken its address. */
+ TREE_ADDRESSABLE (cloned_parm) = TREE_ADDRESSABLE (parm);
+
+ /* The definition might have different constness. */
+ TREE_READONLY (cloned_parm) = TREE_READONLY (parm);
+
+ TREE_USED (cloned_parm) = TREE_USED (parm);
/* The name may have changed from the declaration. */
DECL_NAME (cloned_parm) = DECL_NAME (parm);
DECL_SOURCE_FILE (cloned_parm) = DECL_SOURCE_FILE (parm);
DECL_SOURCE_LINE (cloned_parm) = DECL_SOURCE_LINE (parm);
-
}
/* FN is a function that has a complete body. Clone the body as
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index a39d8cc..79d4f0a 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2001-05-20 Nathan Sidwell <nathan@codesourcery.com>
+
+ * g++.old-deja/g++.other/optimize1.C: New test.
+
2001-05-20 Kriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net>
* g++.old-deja/g++.pt/spec41.C: New test.
diff --git a/gcc/testsuite/g++.old-deja/g++.other/optimize1.C b/gcc/testsuite/g++.old-deja/g++.other/optimize1.C
new file mode 100644
index 0000000..bff78dc
--- /dev/null
+++ b/gcc/testsuite/g++.old-deja/g++.other/optimize1.C
@@ -0,0 +1,70 @@
+// Special g++ Options: -O2
+//
+// Copyright (C) 2001 Free Software Foundation, Inc.
+// Contributed by Nathan Sidwell 18 May 2001 <nathan@codesourcery.com>
+
+// Bug 2781. We forgot to copy addressability information when
+// cloning.
+
+struct B
+{
+ B(int v1);
+ void Member (int v1);
+ static void Static (int v1);
+};
+
+struct D : B
+{
+ D (int v1);
+};
+
+void xswap(int& x1) ;
+
+int xxx = 0;
+
+B::B(int v1)
+{
+ xswap(v1);
+ xxx = v1;
+}
+
+void B::Member(int v1)
+{
+ xswap(v1);
+ xxx = v1;
+}
+
+void B::Static(int v1)
+{
+ xswap(v1);
+ xxx = v1;
+}
+
+D::D(int v1)
+ : B (v1)
+{
+}
+
+void xswap (int& x1) { x1 = 2; }
+
+int main ()
+{
+ B p (1);
+
+ if (xxx != 2)
+ return 1;
+
+ D q (1);
+ if (xxx != 2)
+ return 2;
+
+ p.Member (1);
+ if (xxx != 2)
+ return 3;
+
+ p.Static (1);
+ if (xxx != 2)
+ return 4;
+
+ return 0;
+}