diff options
Diffstat (limited to 'gcc/testsuite/g++.dg/compat/break')
21 files changed, 261 insertions, 0 deletions
diff --git a/gcc/testsuite/g++.dg/compat/break/README b/gcc/testsuite/g++.dg/compat/break/README new file mode 100644 index 000000000..0b8ea0247 --- /dev/null +++ b/gcc/testsuite/g++.dg/compat/break/README @@ -0,0 +1,18 @@ +Tests in this directory are for functionality that has changed in GCC +from one release to another or that is not ABI-compliant and may change +in a future release. + +Each test header for changed behavior should indicate the version in +which the behavior changed, in order to help users of these tests to +determine whether a test failure is expected or not. + +Every test in this directory that covers behavior that is not +ABI-compliant should also be covered by a test for -Wabi to ensure that +there is a warning for the construct. + + +Copyright (C) 2002 Free Software Foundation, Inc. + +Copying and distribution of this file, with or without modification, +are permitted in any medium without royalty provided the copyright +notice and this notice are preserved. diff --git a/gcc/testsuite/g++.dg/compat/break/bitfield5.h b/gcc/testsuite/g++.dg/compat/break/bitfield5.h new file mode 100644 index 000000000..6f7f012cc --- /dev/null +++ b/gcc/testsuite/g++.dg/compat/break/bitfield5.h @@ -0,0 +1,11 @@ +struct A { + virtual void f(); + int f1 : 1; +}; + +struct B : public A { + int f2 : 1; + int : 0; + int f3 : 4; + int f4 : 3; +}; diff --git a/gcc/testsuite/g++.dg/compat/break/bitfield5_main.C b/gcc/testsuite/g++.dg/compat/break/bitfield5_main.C new file mode 100644 index 000000000..415a8846c --- /dev/null +++ b/gcc/testsuite/g++.dg/compat/break/bitfield5_main.C @@ -0,0 +1,14 @@ +// The offset of `B::f2' is not ABI-compliant and may change in a future +// version of GCC. +// g++.dg/abi/bitfield5.C tests this with -Wabi. +// Split into pieces for binary compatibility testing October 2002 + +#include "bitfield5.h" + +extern void bitfield5_x (void); + +int +main () +{ + bitfield5_x (); +} diff --git a/gcc/testsuite/g++.dg/compat/break/bitfield5_x.C b/gcc/testsuite/g++.dg/compat/break/bitfield5_x.C new file mode 100644 index 000000000..9be937234 --- /dev/null +++ b/gcc/testsuite/g++.dg/compat/break/bitfield5_x.C @@ -0,0 +1,13 @@ +#include "bitfield5.h" + +extern void bitfield5_y (B&); + +void bitfield5_x () +{ + B b; + + b.f3 = 7; + b.f4 = 3; + + bitfield5_y (b); +} diff --git a/gcc/testsuite/g++.dg/compat/break/bitfield5_y.C b/gcc/testsuite/g++.dg/compat/break/bitfield5_y.C new file mode 100644 index 000000000..6ee4dd008 --- /dev/null +++ b/gcc/testsuite/g++.dg/compat/break/bitfield5_y.C @@ -0,0 +1,13 @@ +extern "C" void abort (void); + +#include "bitfield5.h" + +void A::f () {} + +void bitfield5_y (B& b) +{ + if (b.f3 != 7) + abort (); + if (b.f4 != 3) + abort (); +} diff --git a/gcc/testsuite/g++.dg/compat/break/bitfield7.h b/gcc/testsuite/g++.dg/compat/break/bitfield7.h new file mode 100644 index 000000000..2060bf747 --- /dev/null +++ b/gcc/testsuite/g++.dg/compat/break/bitfield7.h @@ -0,0 +1,3 @@ +union U { + int i: 4096; +}; diff --git a/gcc/testsuite/g++.dg/compat/break/bitfield7_main.C b/gcc/testsuite/g++.dg/compat/break/bitfield7_main.C new file mode 100644 index 000000000..57bb96101 --- /dev/null +++ b/gcc/testsuite/g++.dg/compat/break/bitfield7_main.C @@ -0,0 +1,16 @@ +// { dg-options "-w" } + +// The size assigned to `U' may not be ABI-compliant and may change in a +// future version of GCC. +// g++.dg/abi/bitfield7.C tests this with -Wabi. +// Split into pieces for binary compatibility testing October 2002 + +#include "bitfield7.h" + +extern void bitfield7_x (void); + +int +main () +{ + bitfield7_x (); +} diff --git a/gcc/testsuite/g++.dg/compat/break/bitfield7_x.C b/gcc/testsuite/g++.dg/compat/break/bitfield7_x.C new file mode 100644 index 000000000..9b2a622a5 --- /dev/null +++ b/gcc/testsuite/g++.dg/compat/break/bitfield7_x.C @@ -0,0 +1,15 @@ +// { dg-options "-w" } + +#include "bitfield7.h" + +extern void bitfield7_y (U*); + +void bitfield7_x () +{ + U u[2]; + + u[0].i = 7; + u[1].i = 8; + + bitfield7_y (u); +} diff --git a/gcc/testsuite/g++.dg/compat/break/bitfield7_y.C b/gcc/testsuite/g++.dg/compat/break/bitfield7_y.C new file mode 100644 index 000000000..afa5446ae --- /dev/null +++ b/gcc/testsuite/g++.dg/compat/break/bitfield7_y.C @@ -0,0 +1,13 @@ +// { dg-options "-w" } + +extern "C" void abort (void); + +#include "bitfield7.h" + +void bitfield7_y (U* u) +{ + if (u[0].i != 7) + abort (); + if (u[1].i != 8) + abort (); +} diff --git a/gcc/testsuite/g++.dg/compat/break/empty6.h b/gcc/testsuite/g++.dg/compat/break/empty6.h new file mode 100644 index 000000000..47a0da8b5 --- /dev/null +++ b/gcc/testsuite/g++.dg/compat/break/empty6.h @@ -0,0 +1,7 @@ +struct A {}; + +struct B { + A a; + virtual void f () {} + int i; +}; diff --git a/gcc/testsuite/g++.dg/compat/break/empty6_main.C b/gcc/testsuite/g++.dg/compat/break/empty6_main.C new file mode 100644 index 000000000..bf6d98241 --- /dev/null +++ b/gcc/testsuite/g++.dg/compat/break/empty6_main.C @@ -0,0 +1,14 @@ +// `B::a' contains empty classes which may cause base classes to be +// placed at different locations in a future version of GCC. +// g++.dg/abi/empty6.C tests this with -Wabi. +// Split into pieces for binary compatibility testing October 2002 + +#include "empty6.h" + +extern void empty6_x (void); + +int +main () +{ + empty6_x (); +} diff --git a/gcc/testsuite/g++.dg/compat/break/empty6_x.C b/gcc/testsuite/g++.dg/compat/break/empty6_x.C new file mode 100644 index 000000000..f7e25e9ab --- /dev/null +++ b/gcc/testsuite/g++.dg/compat/break/empty6_x.C @@ -0,0 +1,12 @@ +#include "empty6.h" + +extern void empty6_y (B&); + +void empty6_x () +{ + B b; + + b.i = 7; + + empty6_y (b); +} diff --git a/gcc/testsuite/g++.dg/compat/break/empty6_y.C b/gcc/testsuite/g++.dg/compat/break/empty6_y.C new file mode 100644 index 000000000..cb3d45c9e --- /dev/null +++ b/gcc/testsuite/g++.dg/compat/break/empty6_y.C @@ -0,0 +1,9 @@ +extern "C" void abort (void); + +#include "empty6.h" + +void empty6_y (B& b) +{ + if (b.i != 7) + abort (); +} diff --git a/gcc/testsuite/g++.dg/compat/break/vbase10.h b/gcc/testsuite/g++.dg/compat/break/vbase10.h new file mode 100644 index 000000000..f418d1e56 --- /dev/null +++ b/gcc/testsuite/g++.dg/compat/break/vbase10.h @@ -0,0 +1,12 @@ +struct A { + virtual void f(); + char c1; +}; + +struct B { + B(); + char c2; +}; + +struct C : public A, public virtual B { +}; diff --git a/gcc/testsuite/g++.dg/compat/break/vbase10_main.C b/gcc/testsuite/g++.dg/compat/break/vbase10_main.C new file mode 100644 index 000000000..a082b5dbf --- /dev/null +++ b/gcc/testsuite/g++.dg/compat/break/vbase10_main.C @@ -0,0 +1,14 @@ +// The offset of virtual base `B' is not ABI-compliant and may change in +// a future version of GCC. +// g++.dg/abi/vbase10.C tests this with -Wabi. +// Split into pieces for binary compatibility testing October 2002 + +#include "vbase10.h" + +extern void vbase10_x (void); + +int +main () +{ + vbase10_x (); +} diff --git a/gcc/testsuite/g++.dg/compat/break/vbase10_x.C b/gcc/testsuite/g++.dg/compat/break/vbase10_x.C new file mode 100644 index 000000000..6d51d3c72 --- /dev/null +++ b/gcc/testsuite/g++.dg/compat/break/vbase10_x.C @@ -0,0 +1,13 @@ +#include "vbase10.h" + +extern void vbase10_y (C&); + +void vbase10_x () +{ + C c; + + c.c1 = 1; + c.c2 = 2; + + vbase10_y (c); +} diff --git a/gcc/testsuite/g++.dg/compat/break/vbase10_y.C b/gcc/testsuite/g++.dg/compat/break/vbase10_y.C new file mode 100644 index 000000000..70ce0075e --- /dev/null +++ b/gcc/testsuite/g++.dg/compat/break/vbase10_y.C @@ -0,0 +1,14 @@ +extern "C" void abort (void); + +#include "vbase10.h" + +void A::f () {} +B::B() {} + +void vbase10_y (C& c) +{ + if (c.c1 != 1) + abort (); + if (c.c2 != 2) + abort (); +} diff --git a/gcc/testsuite/g++.dg/compat/break/vbase11.h b/gcc/testsuite/g++.dg/compat/break/vbase11.h new file mode 100644 index 000000000..a298f7644 --- /dev/null +++ b/gcc/testsuite/g++.dg/compat/break/vbase11.h @@ -0,0 +1,12 @@ +struct base +{ + short b; + virtual int foo(); +}; + +struct derived: virtual base +{ + int d; + virtual int foo(); + virtual int bar(); +}; diff --git a/gcc/testsuite/g++.dg/compat/break/vbase11_main.C b/gcc/testsuite/g++.dg/compat/break/vbase11_main.C new file mode 100644 index 000000000..2ac599449 --- /dev/null +++ b/gcc/testsuite/g++.dg/compat/break/vbase11_main.C @@ -0,0 +1,13 @@ +// Test case from PR 7470, which was fixed in GCC 3.2 and breaks binary +// compatibility with earlier releases. +// Split into pieces for binary compatibility testing October 2002 + +#include "vbase11.h" + +extern void vbase11_x (void); + +int +main () +{ + vbase11_x (); +} diff --git a/gcc/testsuite/g++.dg/compat/break/vbase11_x.C b/gcc/testsuite/g++.dg/compat/break/vbase11_x.C new file mode 100644 index 000000000..4b2398ae1 --- /dev/null +++ b/gcc/testsuite/g++.dg/compat/break/vbase11_x.C @@ -0,0 +1,14 @@ +#include "vbase11.h" + +extern void vbase11_y (derived&); + +int base::foo() { return 1; } +int derived::foo() { return 2; } +int derived::bar() { return 3; } + +void vbase11_x () +{ + derived d; + + vbase11_y (d); +} diff --git a/gcc/testsuite/g++.dg/compat/break/vbase11_y.C b/gcc/testsuite/g++.dg/compat/break/vbase11_y.C new file mode 100644 index 000000000..01ca62b87 --- /dev/null +++ b/gcc/testsuite/g++.dg/compat/break/vbase11_y.C @@ -0,0 +1,11 @@ +extern "C" void abort (void); + +#include "vbase11.h" + +void vbase11_y (derived& d) +{ + if (d.foo() != 2) + abort (); + if (d.bar() != 3) + abort (); +} |