aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorNathan Sidwell <nathan@codesourcery.com>2001-09-04 12:21:33 +0000
committerNathan Sidwell <nathan@gcc.gnu.org>2001-09-04 12:21:33 +0000
commitda86f08fd77a8fdc841d4b9dfdc732efcbe4099a (patch)
treed3159834db6bf3e5d1d3890dd1e04ff5b26af491 /gcc
parent223671612fba9ad84298792fa5dcfe1675be9084 (diff)
downloadgcc-da86f08fd77a8fdc841d4b9dfdc732efcbe4099a.zip
gcc-da86f08fd77a8fdc841d4b9dfdc732efcbe4099a.tar.gz
gcc-da86f08fd77a8fdc841d4b9dfdc732efcbe4099a.tar.bz2
re PR c++/4203 (empty base class optimization zeroes first byte of other base class when using multiple inheritance)
cp: PR c++/4203 * call.c (build_over_call): Do not optimize any empty base construction. testsuite: PR c++/4203 * g++.old-deja/g++.other/empty1.C: XFAIL. See PR c++/4222 * g++.dg/init/empty1.C: New test. From-SVN: r45374
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/call.c6
-rw-r--r--gcc/testsuite/ChangeLog6
-rw-r--r--gcc/testsuite/g++.dg/init/empty1.C30
-rw-r--r--gcc/testsuite/g++.old-deja/g++.other/empty1.C6
5 files changed, 51 insertions, 3 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 8dc0b86f..28ef9f7 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,9 @@
+2001-09-04 Nathan Sidwell <nathan@codesourcery.com>
+
+ PR c++/4203
+ * call.c (build_over_call): Do not optimize any empty base
+ construction.
+
2001-08-31 Kriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net>
* error.c (dump_template_decl): Output template parameters
diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index 74caa38..9caae4b 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -4258,14 +4258,14 @@ build_over_call (cand, args, flags)
else if (TYPE_HAS_TRIVIAL_INIT_REF (DECL_CONTEXT (fn)))
return build_target_expr_with_type (arg, DECL_CONTEXT (fn));
}
- else if (! real_lvalue_p (arg)
+ else if ((!real_lvalue_p (arg)
+ || TYPE_HAS_TRIVIAL_INIT_REF (DECL_CONTEXT (fn)))
/* Empty classes have padding which can be hidden
inside an (empty) base of the class. This must not
be touched as it might overlay things. When the
gcc core learns about empty classes, we can treat it
like other classes. */
- || (!is_empty_class (DECL_CONTEXT (fn))
- && TYPE_HAS_TRIVIAL_INIT_REF (DECL_CONTEXT (fn))))
+ && !is_empty_class (DECL_CONTEXT (fn)))
{
tree address;
tree to = stabilize_reference
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index b76142b..927522a 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,9 @@
+2001-09-04 Nathan Sidwell <nathan@codesourcery.com>
+
+ PR c++/4203
+ * g++.old-deja/g++.other/empty1.C: XFAIL. See PR c++/4222
+ * g++.dg/init/empty1.C: New test.
+
2001-09-03 Jakub Jelinek <jakub@redhat.com>
* gcc.c-torture/compile/20010903-1.c: New test.
diff --git a/gcc/testsuite/g++.dg/init/empty1.C b/gcc/testsuite/g++.dg/init/empty1.C
new file mode 100644
index 0000000..bba179f
--- /dev/null
+++ b/gcc/testsuite/g++.dg/init/empty1.C
@@ -0,0 +1,30 @@
+// { dg-do run }
+
+// Copyright (C) 2001 Free Software Foundation, Inc.
+// Contributed by Nathan Sidwell 3 Sept 2001 <nathan@codesourcery.com>
+
+// Bug 4203. We were bit copying empty bases including the
+// padding. Which clobbers whatever they overlay.
+
+class EmptyBase0 {};
+class EmptyBase1 : public EmptyBase0 {};
+class Base1
+{
+public:
+unsigned int t_;
+Base1(unsigned int t) : t_(t) {}
+};
+
+class PEPE : public Base1, public EmptyBase1
+{
+public:
+PEPE(unsigned int t)
+ : Base1(t), EmptyBase1(EmptyBase1()) {}
+};
+
+int main()
+{
+ PEPE pepe(0xff);
+
+ return pepe.t_ != 255;
+}
diff --git a/gcc/testsuite/g++.old-deja/g++.other/empty1.C b/gcc/testsuite/g++.old-deja/g++.other/empty1.C
index 1210327..a876ce8 100644
--- a/gcc/testsuite/g++.old-deja/g++.other/empty1.C
+++ b/gcc/testsuite/g++.old-deja/g++.other/empty1.C
@@ -1,4 +1,10 @@
// Origin: Mark Mitchell <mark@codesourcery.com>
+// This test case checks that the return value optimization works for
+// empty classes.
+
+// xfailed because empty classes clobbering what they overlay as the
+// backend treats them as single byte objects. See bug 4222
+// execution test - XFAIL *-*-*
extern "C" void abort();
extern "C" int printf (const char *, ...);