diff options
author | H.J. Lu <hongjiu.lu@intel.com> | 2010-07-23 19:37:40 +0000 |
---|---|---|
committer | H.J. Lu <hongjiu.lu@intel.com> | 2010-07-23 19:37:40 +0000 |
commit | e59b0ef2e7a1fb44791d473ee416aeb01fcb169c (patch) | |
tree | 437dca120093cc7b1f6debf6f6b31779526c7192 /gcc/testsuite/g++.dg/inherit/covariant17.C | |
parent | f25b023a0d9de6a6c1e1965d93ba6028cb03fc7d (diff) | |
parent | 92ac755201aad4366eaff2b75b3239637bee3590 (diff) |
Merged with trunk at revision 162480.ifunc
git-svn-id: https://gcc.gnu.org/svn/gcc/branches/ifunc@162483 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/testsuite/g++.dg/inherit/covariant17.C')
-rw-r--r-- | gcc/testsuite/g++.dg/inherit/covariant17.C | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/gcc/testsuite/g++.dg/inherit/covariant17.C b/gcc/testsuite/g++.dg/inherit/covariant17.C new file mode 100644 index 00000000000..b2de15f7ed6 --- /dev/null +++ b/gcc/testsuite/g++.dg/inherit/covariant17.C @@ -0,0 +1,43 @@ +// PR c++/43120 +// { dg-do run } + +extern "C" void abort (); + +struct A { + int a; + + A(int a_) : a(a_) {} + + A(const A &other) { } + + virtual void dummy() {} +}; + +struct B { + virtual B *clone() const = 0; +}; + +struct C : public virtual B { + virtual C *clone() const = 0; +}; + +struct E* ep; +struct E : public A, public C { + E(int a_) : A(a_) { ep = this; } + + virtual E *clone() const { + if (this != ep) + abort(); + return 0; + } +}; + +int main() { + E *a = new E(123); + C *c = a; + B *b = a; + c->clone(); + b->clone(); + delete a; + return 0; +} |