+2002-10-17 Janis Johnson <janis187@us.ibm.com>
+
+ * g++.dg/README: Describe new compat directory.
+ * g++.dg/dg.exp: Skip tests in compat directory.
+ * README.compat: New file.
+ * lib/compat.exp: New expect script.
+ * g++.dg/compat: New test directory.
+ * g++.dg/compat/compat.exp: New expect script.
+ * g++.dg/compat/abi: New test directory.
+ * g++.dg/compat/abi/bitfield1_x.C, g++.dg/compat/abi/bitfield1_main.C,
+ g++.dg/compat/abi/bitfield1_y.C, g++.dg/compat/abi/bitfield1.h,
+ g++.dg/compat/abi/bitfield2_x.C, g++.dg/compat/abi/bitfield2_main.C,
+ g++.dg/compat/abi/bitfield2_y.C, g++.dg/compat/abi/bitfield2.h,
+ g++.dg/compat/abi/vbase8-10_x.C, g++.dg/compat/abi/vbase8-10_main.C,
+ g++.dg/compat/abi/vbase8-10_y.C, g++.dg/compat/abi/vbase8-10.h,
+ g++.dg/compat/abi/vbase8-21_x.C, g++.dg/compat/abi/vbase8-21_main.C,
+ g++.dg/compat/abi/vbase8-21_y.C, g++.dg/compat/abi/vbase8-21.h,
+ g++.dg/compat/abi/vbase8-22_x.C, g++.dg/compat/abi/vbase8-22_main.C,
+ g++.dg/compat/abi/vbase8-22_y.C, g++.dg/compat/abi/vbase8-22.h,
+ g++.dg/compat/abi/vbase8-4_x.C, g++.dg/compat/abi/vbase8-4_main.C,
+ g++.dg/compat/abi/vbase8-4_y.C, g++.dg/compat/abi/vbase8-4.h: New files.
+ * g++.dg/compat/break: New test directory.
+ * g++.dg/compat/break/empty6_x.C, g++.dg/compat/break/empty6_main.C,
+ g++.dg/compat/break/empty6_y.C, g++.dg/compat/break/empty6.h,
+ g++.dg/compat/break/vbase10_x.C, g++.dg/compat/break/vbase10_main.C,
+ g++.dg/compat/break/vbase10_y.C, g++.dg/compat/break/vbase10.h,
+ g++.dg/compat/break/vbase11_x.C, g++.dg/compat/break/vbase11_main.C,
+ g++.dg/compat/break/vbase11_y.C, g++.dg/compat/break/vbase11.h,
+ g++.dg/compat/break/bitfield7_x.C, g++.dg/compat/break/bitfield7_main.C,
+ g++.dg/compat/break/bitfield7_y.C, g++.dg/compat/break/bitfield7.h,
+ g++.dg/compat/break/bitfield5_x.C, g++.dg/compat/break/bitfield5_main.C,
+ g++.dg/compat/break/bitfield5_y.C, g++.dg/compat/break/bitfield5.h,
+ g++.dg/compat/break/README: New files.
+ * g++.dg/compat/eh: New test directory.
+ * g++.dg/compat/eh/ctor1_x.C, g++.dg/compat/eh/ctor1_main.C,
+ g++.dg/compat/eh/ctor1_y.C, g++.dg/compat/eh/ctor1.h,
+ g++.dg/compat/eh/ctor2_x.C, g++.dg/compat/eh/ctor2_main.C,
+ g++.dg/compat/eh/ctor2_y.C, g++.dg/compat/eh/ctor2.h,
+ g++.dg/compat/eh/dtor1_x.C, g++.dg/compat/eh/dtor1_main.C,
+ g++.dg/compat/eh/dtor1_y.C, g++.dg/compat/eh/dtor1.h,
+ g++.dg/compat/eh/filter1_x.C, g++.dg/compat/eh/filter1_main.C,
+ g++.dg/compat/eh/filter1_y.C, g++.dg/compat/eh/filter1.h,
+ g++.dg/compat/eh/filter2_x.C, g++.dg/compat/eh/filter2_main.C,
+ g++.dg/compat/eh/filter2_y.C,
+ g++.dg/compat/eh/new1_x.C, g++.dg/compat/eh/new1_main.C,
+ g++.dg/compat/eh/new1_y.C,
+ g++.dg/compat/eh/nrv1_x.C, g++.dg/compat/eh/nrv1_main.C,
+ g++.dg/compat/eh/nrv1_y.C, g++.dg/compat/eh/nrv1.h,
+ g++.dg/compat/eh/spec3_x.C, g++.dg/compat/eh/spec3_main.C,
+ g++.dg/compat/eh/spec3_y.C, g++.dg/compat/eh/spec3.h,
+ g++.dg/compat/eh/template1_x.C, g++.dg/compat/eh/template1_main.C,
+ g++.dg/compat/eh/template1_y.C, g++.dg/compat/eh/template1.h,
+ g++.dg/compat/eh/unexpected1_x.C, g++.dg/compat/eh/unexpected1_main.C,
+ g++.dg/compat/eh/unexpected1_y.C: New files.
+ * g++.dg/compat/init: New test directory.
+ * g++.dg/compat/init/array5_x.C, g++.dg/compat/init/array5_main.C,
+ g++.dg/compat/init/array5_y.C,
+ g++.dg/compat/init/byval1_x.C, g++.dg/compat/init/byval1_main.C,
+ g++.dg/compat/init/byval1_y.C, g++.dg/compat/init/byval1.h,
+ g++.dg/compat/init/dtor1_x.C, g++.dg/compat/init/dtor1_main.C,
+ g++.dg/compat/init/dtor1_y.C, g++.dg/compat/init/dtor1.h,
+ g++.dg/compat/init/elide1_x.C, g++.dg/compat/init/elide1_main.C,
+ g++.dg/compat/init/elide1_y.C, g++.dg/compat/init/elide1.h,
+ g++.dg/compat/init/init-ref2_x.C, g++.dg/compat/init/init-ref2_main.C,
+ g++.dg/compat/init/init-ref2_y.C: New files.
+
2002-10-17 Mark Mitchell <mark@codesourcery.com>
PR c++/7584
--- /dev/null
+Compatibility test suites that use lib/compat.exp test interoperability
+of two compilers that follow the same ABI, or of multiple sets of
+compiler options that are not intended to affect binary compatibility.
+They do not test conformance to a formal ABI; they check that things are
+done consistently, not that they are done correctly. They are meant to
+complement ABI test suites, not to replace them.
+
+Each test in these suites splits up functionality into two source files
+that can be compiled with two different versions of GCC and with two
+sets of compiler options.
+
+ Override the default pairs of compiler options (from compat.exp) by
+ defining the environment variable COMPAT_OPTIONS as:
+ COMPAT_OPTIONS="[list [list {tst1} {alt1}]...[list {tstn} {altn}]]"
+ where tsti and alti are lists of options, with "tsti" used by the
+ compiler under test and "alti" used by the alternate compiler. The
+ characters "[", "{", "}", and "]" are really in the string, as in
+ "[list [list {-g} {-O3}] [list {-O3} {-g}]]".
+
+ To use an alternate compiler, define the environment variable for the
+ language you're testing; e.g., for C++ define ALT_CXX_UNDER_TEST to be
+ the full pathname of an installed compiler. That will be written to
+ the site.exp file used by DejaGNU. The default is to build each test
+ with the compiler under test using the first of each pair of compiler
+ options from COMPAT_OPTIONS. When ALT_CXX_UNDER_TEST is "same", each
+ test is built using the compiler under test but with combinations of
+ the options from COMPAT_OPTIONS.
+
+A test that fails when the pieces are compiled with different compilers
+but passes when the pieces are compiled with the same compiler
+demonstrates incompatibility of the generated code or runtime support.
+A test that fails for the alternate compiler but passes for the compiler
+under test probably tests for a fix that is not present in the alternate
+compiler.
+
+There's a lot more that can be done with these tests.
+
+ Increase the robustness of the existing tests:
+
+ - recognize target triples in dg-options strings in test files
+
+ - continue to split up tests that rely on language runtime support
+ and add them to this set of tests
+
+ - make sure they work for testing with a simulator
+
+ - multilibs support?
+
+ Build test pieces into more combinations that will be likely to find
+ unusual errors:
+
+ - link using the alternate compiler; this requires support for
+ LD_LIBRARY_PATH for the alternate compiler in the support for each
+ language
+
+ - build pieces of the test into shared libraries; this requires
+ support for LD_LIBRARY_PATH for the alternate compiler, and
+ knowledge about how to build a shared library for each target
+
+ - build pieces of the test into static libraries; this requires
+ knowledge about how to build a static library for each target
+
+ Continue to add tests to g++.dg/compat, based on existing tests for
+ language runtime support and for test cases in PRs that didn't used to
+ fit into the test suite.
+
+ Set up similar tests in libstdc++-v3/testsuite.
+
+ Set up similar tests for additional languages and libraries.
+
+Janis Johnson, <janis187@us.ibm.com>
+October 2002
Subdirectories:
abi Tests for ABI compatibility -- mangling, object layout, etc.
+compat Tests for binary compatibility (consistency, not ABI conformance)
cpp Tests for the preprocessor.
eh Tests for exception handling.
expr Tests for expressions.
--- /dev/null
+typedef int Int;
+typedef signed int SInt;
+typedef unsigned int UInt;
+
+struct A
+{
+ SInt bitS : 1; // signed
+ UInt bitU : 1; // unsigned
+ Int bit : 1; // signedness by -f{signed,unsigned}-bitfields
+};
--- /dev/null
+// { dg-options "-ansi -pedantic-errors -funsigned-bitfields" }
+
+// Copyright (C) 2001 Free Software Foundation, Inc.
+// Contributed by Nathan Sidwell 15 Dec 2001 <nathan@codesourcery.com>
+// Split into pieces for binary compatibility testing October 2002
+
+extern void bitfield1_x (void);
+
+int
+main ()
+{
+ bitfield1_x ();
+}
--- /dev/null
+#include "bitfield1.h"
+
+extern void bitfield1_y (A& a);
+
+void bitfield1_x ()
+{
+ A a;
+
+ a.bitS = 1;
+ a.bitU = 1;
+ a.bit = 1;
+
+ bitfield1_y (a);
+}
--- /dev/null
+extern "C" void abort (void);
+
+#include "bitfield1.h"
+
+void bitfield1_y (A& a)
+{
+ if (a.bitS != -1)
+ abort ();
+ if (a.bitU != 1)
+ abort ();
+ if (a.bit != 1)
+ abort ();
+}
--- /dev/null
+typedef int Int;
+typedef signed int SInt;
+typedef unsigned int UInt;
+
+struct A
+{
+ SInt bitS : 1; // signed
+ UInt bitU : 1; // unsigned
+ Int bit : 1; // signedness by -f{signed,unsigned}-bitfields
+};
--- /dev/null
+// { dg-options "-ansi -pedantic-errors -fsigned-bitfields" }
+
+// Copyright (C) 2001 Free Software Foundation, Inc.
+// Contributed by Nathan Sidwell 15 Dec 2001 <nathan@codesourcery.com>
+// Split into pieces for binary compatibility testing October 2002
+
+extern void bitfield1_x (void);
+
+int
+main ()
+{
+ bitfield1_x ();
+}
--- /dev/null
+#include "bitfield1.h"
+
+extern void bitfield1_y (A& a);
+
+void bitfield1_x ()
+{
+ A a;
+
+ a.bitS = 1;
+ a.bitU = 1;
+ a.bit = 1;
+
+ bitfield1_y (a);
+}
--- /dev/null
+extern "C" void abort (void);
+
+#include "bitfield1.h"
+
+void bitfield1_y (A& a)
+{
+ if (a.bitS != -1)
+ abort ();
+ if (a.bitU != 1)
+ abort ();
+ if (a.bit != -1)
+ abort ();
+}
--- /dev/null
+class C0
+{ public: int i0; };
+class C1
+ : public C0
+{ public: int i1; };
+class C2
+ : public C1
+ , virtual public C0
+{ public: int i2; };
+class C3
+ : public C1
+ , public C2
+ , virtual public C0
+{ public: int i3; };
+class C4
+ : virtual public C1
+ , virtual public C0
+ , virtual public C3
+ , public C2
+{ public: int i4; };
+class C5
+ : public C3
+ , virtual public C0
+ , virtual public C2
+{ public: int i5; };
+class C6
+ : public C1
+ , public C2
+ , virtual public C5
+ , virtual public C3
+ , virtual public C0
+{ public: int i6; };
+class C7
+ : public C1
+ , virtual public C5
+ , virtual public C4
+ , virtual public C2
+ , virtual public C0
+ , virtual public C6
+{ public: int i7; };
+class C8
+ : virtual public C4
+ , public C3
+ , public C0
+ , virtual public C7
+ , virtual public C6
+{ public: int i8; };
+class C9
+ : virtual public C0
+ , public C4
+ , public C8
+ , public C1
+ , public C6
+{ public: int i9; };
--- /dev/null
+// { dg-options -w }
+
+// Copyright (C) 2001 Free Software Foundation, Inc.
+// Contributed by Nathan Sidwell 26 Jul 2001 <nathan@codesourcery.com>
+// Split into pieces for binary compatibility testing October 2002
+
+// Origin stefan@space.twc.de
+// Bug 3145 case 10. Horribly complicated class hierarchy
+
+extern void vbase8_10_x (void);
+
+int
+main ()
+{
+ vbase8_10_x ();
+}
--- /dev/null
+#include "vbase8-10.h"
+
+extern void check_C0 (C0&, int);
+extern void check_C1 (C1&, int);
+extern void check_C2 (C2&, int);
+extern void check_C3 (C3&, int);
+extern void check_C4 (C4&, int);
+extern void check_C5 (C5&, int);
+extern void check_C6 (C6&, int);
+extern void check_C7 (C7&, int);
+extern void check_C8 (C8&, int);
+extern void check_C9 (C9&, int);
+
+void
+vbase8_10_x (void)
+{
+ C0 c0;
+ C1 c1;
+ C2 c2;
+ C3 c3;
+ C4 c4;
+ C5 c5;
+ C6 c6;
+ C7 c7;
+ C8 c8;
+ C9 c9;
+
+ c0.i0 = 0;
+ c1.i1 = 101;
+ c2.i2 = 202;
+ c3.i3 = 303;
+ c4.i4 = 404;
+ c5.i5 = 505;
+ c6.i6 = 606;
+ c7.i7 = 707;
+ c8.i8 = 808;
+ c9.i9 = 909;
+
+ check_C0 (c0, 0);
+ check_C1 (c1, 101);
+ check_C2 (c2, 202);
+ check_C3 (c3, 303);
+ check_C4 (c4, 404);
+ check_C5 (c5, 505);
+ check_C6 (c6, 606);
+ check_C7 (c7, 707);
+ check_C8 (c8, 808);
+ check_C9 (c9, 909);
+}
--- /dev/null
+extern "C" void abort (void);
+
+#include "vbase8-10.h"
+
+void check_C0 (C0 &x, int i)
+{
+ if (x.i0 != i)
+ abort ();
+}
+
+void check_C1 (C1 &x, int i)
+{
+ if (x.i1 != i)
+ abort ();
+}
+
+void check_C2 (C2 &x, int i)
+{
+ if (x.i2 != i)
+ abort ();
+}
+
+void check_C3 (C3 &x, int i)
+{
+ if (x.i3 != i)
+ abort ();
+}
+
+void check_C4 (C4 &x, int i)
+{
+ if (x.i4 != i)
+ abort ();
+}
+
+void check_C5 (C5 &x, int i)
+{
+ if (x.i5 != i)
+ abort ();
+}
+
+void check_C6 (C6 &x, int i)
+{
+ if (x.i6 != i)
+ abort ();
+}
+
+void check_C7 (C7 &x, int i)
+{
+ if (x.i7 != i)
+ abort ();
+}
+
+void check_C8 (C8 &x, int i)
+{
+ if (x.i8 != i)
+ abort ();
+}
+
+void check_C9 (C9 &x, int i)
+{
+ if (x.i9 != i)
+ abort ();
+}
--- /dev/null
+class C0
+{ public: int i0; };
+class C1
+ : virtual public C0
+{ public: int i1; };
+class C2
+ : virtual public C1
+ , virtual public C0
+{ public: int i2; };
+class C3
+ : virtual public C2
+ , virtual public C1
+{ public: int i3; };
+class C4
+ : virtual public C2
+ , public C0
+ , public C1
+{ public: int i4; };
+class C5
+ : virtual public C0
+ , public C2
+ , virtual public C1
+ , virtual public C3
+ , virtual public C4
+{ public: int i5; };
+class C6
+ : virtual public C1
+ , virtual public C3
+ , public C0
+ , public C2
+ , virtual public C4
+{ public: int i6; };
+class C7
+ : virtual public C5
+ , public C2
+ , public C6
+ , virtual public C0
+ , public C3
+{ public: int i7; };
+class C8
+ : virtual public C5
+ , public C7
+ , virtual public C0
+ , virtual public C2
+ , virtual public C6
+{ public: int i8; };
+class C9
+ : virtual public C2
+ , virtual public C4
+ , public C1
+ , virtual public C0
+ , public C7
+ , public C5
+{ public: int i9; };
--- /dev/null
+// { dg-options -w }
+
+// Copyright (C) 2001 Free Software Foundation, Inc.
+// Contributed by Nathan Sidwell 26 Jul 2001 <nathan@codesourcery.com>
+// Split into pieces for binary compatibility testing October 2002
+
+// Origin stefan@space.twc.de
+// Bug 3145 case 10. Horribly complicated class hierarchy
+
+extern void vbase8_21_x (void);
+
+int
+main ()
+{
+ vbase8_21_x ();
+}
--- /dev/null
+#include "vbase8-21.h"
+
+extern void check_C0 (C0&, int);
+extern void check_C1 (C1&, int);
+extern void check_C2 (C2&, int);
+extern void check_C3 (C3&, int);
+extern void check_C4 (C4&, int);
+extern void check_C5 (C5&, int);
+extern void check_C6 (C6&, int);
+extern void check_C7 (C7&, int);
+extern void check_C8 (C8&, int);
+extern void check_C9 (C9&, int);
+
+void
+vbase8_21_x (void)
+{
+ C0 c0;
+ C1 c1;
+ C2 c2;
+ C3 c3;
+ C4 c4;
+ C5 c5;
+ C6 c6;
+ C7 c7;
+ C8 c8;
+ C9 c9;
+
+ c0.i0 = 0;
+ c1.i1 = 101;
+ c2.i2 = 202;
+ c3.i3 = 303;
+ c4.i4 = 404;
+ c5.i5 = 505;
+ c6.i6 = 606;
+ c7.i7 = 707;
+ c8.i8 = 808;
+ c9.i9 = 909;
+
+ check_C0 (c0, 0);
+ check_C1 (c1, 101);
+ check_C2 (c2, 202);
+ check_C3 (c3, 303);
+ check_C4 (c4, 404);
+ check_C5 (c5, 505);
+ check_C6 (c6, 606);
+ check_C7 (c7, 707);
+ check_C8 (c8, 808);
+ check_C9 (c9, 909);
+}
--- /dev/null
+extern "C" void abort (void);
+
+#include "vbase8-21.h"
+
+void check_C0 (C0 &x, int i)
+{
+ if (x.i0 != i)
+ abort ();
+}
+
+void check_C1 (C1 &x, int i)
+{
+ if (x.i1 != i)
+ abort ();
+}
+
+void check_C2 (C2 &x, int i)
+{
+ if (x.i2 != i)
+ abort ();
+}
+
+void check_C3 (C3 &x, int i)
+{
+ if (x.i3 != i)
+ abort ();
+}
+
+void check_C4 (C4 &x, int i)
+{
+ if (x.i4 != i)
+ abort ();
+}
+
+void check_C5 (C5 &x, int i)
+{
+ if (x.i5 != i)
+ abort ();
+}
+
+void check_C6 (C6 &x, int i)
+{
+ if (x.i6 != i)
+ abort ();
+}
+
+void check_C7 (C7 &x, int i)
+{
+ if (x.i7 != i)
+ abort ();
+}
+
+void check_C8 (C8 &x, int i)
+{
+ if (x.i8 != i)
+ abort ();
+}
+
+void check_C9 (C9 &x, int i)
+{
+ if (x.i9 != i)
+ abort ();
+}
--- /dev/null
+class C0
+{ public: int i0; };
+class C1
+ : public C0
+{ public: int i1; };
+class C2
+ : public C1
+ , virtual public C0
+{ public: int i2; };
+class C3
+ : virtual public C0
+ , virtual public C2
+ , virtual public C1
+{ public: int i3; };
+class C4
+ : virtual public C2
+ , public C1
+ , virtual public C3
+ , public C0
+{ public: int i4; };
+class C5
+ : virtual public C0
+ , virtual public C4
+ , public C1
+ , virtual public C2
+ , virtual public C3
+{ public: int i5; };
+class C6
+ : public C0
+ , virtual public C1
+ , public C5
+ , public C2
+ , virtual public C3
+ , virtual public C4
+{ public: int i6; };
+class C7
+ : virtual public C1
+ , public C5
+ , virtual public C6
+ , virtual public C4
+ , virtual public C3
+ , virtual public C0
+{ public: int i7; };
+class C8
+ : virtual public C6
+ , virtual public C1
+ , virtual public C2
+ , public C3
+ , virtual public C4
+{ public: int i8; };
+class C9
+ : public C4
+ , virtual public C2
+ , virtual public C8
+ , public C3
+ , public C1
+ , public C6
+ , public C5
+{ public: int i9; };
--- /dev/null
+// { dg-options -w }
+
+// Copyright (C) 2001 Free Software Foundation, Inc.
+// Contributed by Nathan Sidwell 20 Nov 2001 <nathan@codesourcery.com>
+// Split into pieces for binary compatibility testing October 2002
+
+// Origin stefan@space.twc.de
+// Bug 3145 case 22. Horribly complicated class hierarchy
+
+extern void vbase8_22_x (void);
+
+int
+main ()
+{
+ vbase8_22_x ();
+}
--- /dev/null
+#include "vbase8-22.h"
+
+extern void check_C0 (C0&, int);
+extern void check_C1 (C1&, int);
+extern void check_C2 (C2&, int);
+extern void check_C3 (C3&, int);
+extern void check_C4 (C4&, int);
+extern void check_C5 (C5&, int);
+extern void check_C6 (C6&, int);
+extern void check_C7 (C7&, int);
+extern void check_C8 (C8&, int);
+extern void check_C9 (C9&, int);
+
+void
+vbase8_22_x (void)
+{
+ C0 c0;
+ C1 c1;
+ C2 c2;
+ C3 c3;
+ C4 c4;
+ C5 c5;
+ C6 c6;
+ C7 c7;
+ C8 c8;
+ C9 c9;
+
+ c0.i0 = 0;
+ c1.i1 = 101;
+ c2.i2 = 202;
+ c3.i3 = 303;
+ c4.i4 = 404;
+ c5.i5 = 505;
+ c6.i6 = 606;
+ c7.i7 = 707;
+ c8.i8 = 808;
+ c9.i9 = 909;
+
+ check_C0 (c0, 0);
+ check_C1 (c1, 101);
+ check_C2 (c2, 202);
+ check_C3 (c3, 303);
+ check_C4 (c4, 404);
+ check_C5 (c5, 505);
+ check_C6 (c6, 606);
+ check_C7 (c7, 707);
+ check_C8 (c8, 808);
+ check_C9 (c9, 909);
+}
--- /dev/null
+extern "C" void abort (void);
+
+#include "vbase8-22.h"
+
+void check_C0 (C0 &x, int i)
+{
+ if (x.i0 != i)
+ abort ();
+}
+
+void check_C1 (C1 &x, int i)
+{
+ if (x.i1 != i)
+ abort ();
+}
+
+void check_C2 (C2 &x, int i)
+{
+ if (x.i2 != i)
+ abort ();
+}
+
+void check_C3 (C3 &x, int i)
+{
+ if (x.i3 != i)
+ abort ();
+}
+
+void check_C4 (C4 &x, int i)
+{
+ if (x.i4 != i)
+ abort ();
+}
+
+void check_C5 (C5 &x, int i)
+{
+ if (x.i5 != i)
+ abort ();
+}
+
+void check_C6 (C6 &x, int i)
+{
+ if (x.i6 != i)
+ abort ();
+}
+
+void check_C7 (C7 &x, int i)
+{
+ if (x.i7 != i)
+ abort ();
+}
+
+void check_C8 (C8 &x, int i)
+{
+ if (x.i8 != i)
+ abort ();
+}
+
+void check_C9 (C9 &x, int i)
+{
+ if (x.i9 != i)
+ abort ();
+}
--- /dev/null
+class C0
+{ public: int i0; };
+class C1
+ : virtual public C0
+{ public: int i1; };
+class C2
+ : public C0
+ , public C1
+{ public: int i2; };
+class C3
+ : virtual public C0
+ , public C1
+ , public C2
+{ public: int i3; };
+class C4
+ : public C2
+ , public C3
+ , virtual public C1
+ , virtual public C0
+{ public: int i4; };
+class C5
+ : virtual public C2
+ , public C1
+ , public C0
+{ public: int i5; };
+class C6
+ : virtual public C0
+ , virtual public C5
+ , public C1
+ , public C3
+ , public C4
+{ public: int i6; };
+class C7
+ : public C6
+ , virtual public C0
+ , public C1
+ , public C2
+ , virtual public C4
+{ public: int i7; };
+class C8
+ : public C2
+ , virtual public C6
+ , virtual public C7
+ , public C5
+ , public C3
+ , virtual public C4
+{ public: int i8; };
+class C9
+ : public C5
+ , virtual public C3
+ , virtual public C8
+ , public C0
+ , public C2
+ , public C7
+ , public C6
+ , public C4
+{ public: int i9; };
--- /dev/null
+// { dg-options -w }
+
+// Copyright (C) 2001 Free Software Foundation, Inc.
+// Contributed by Nathan Sidwell 20 Nov 2001 <nathan@codesourcery.com>
+// Split into pieces for binary compatibility testing October 2002
+
+// Origin stefan@space.twc.de
+// Bug 3145 case 4. Horribly complicated class hierarchy
+
+extern void vbase8_4_x (void);
+
+int
+main ()
+{
+ vbase8_4_x ();
+}
--- /dev/null
+#include "vbase8-4.h"
+
+extern void check_C0 (C0&, int);
+extern void check_C1 (C1&, int);
+extern void check_C2 (C2&, int);
+extern void check_C3 (C3&, int);
+extern void check_C4 (C4&, int);
+extern void check_C5 (C5&, int);
+extern void check_C6 (C6&, int);
+extern void check_C7 (C7&, int);
+extern void check_C8 (C8&, int);
+extern void check_C9 (C9&, int);
+
+void
+vbase8_4_x (void)
+{
+ C0 c0;
+ C1 c1;
+ C2 c2;
+ C3 c3;
+ C4 c4;
+ C5 c5;
+ C6 c6;
+ C7 c7;
+ C8 c8;
+ C9 c9;
+
+ c0.i0 = 0;
+ c1.i1 = 101;
+ c2.i2 = 202;
+ c3.i3 = 303;
+ c4.i4 = 404;
+ c5.i5 = 505;
+ c6.i6 = 606;
+ c7.i7 = 707;
+ c8.i8 = 808;
+ c9.i9 = 909;
+
+ check_C0 (c0, 0);
+ check_C1 (c1, 101);
+ check_C2 (c2, 202);
+ check_C3 (c3, 303);
+ check_C4 (c4, 404);
+ check_C5 (c5, 505);
+ check_C6 (c6, 606);
+ check_C7 (c7, 707);
+ check_C8 (c8, 808);
+ check_C9 (c9, 909);
+}
--- /dev/null
+extern "C" void abort (void);
+
+#include "vbase8-4.h"
+
+void check_C0 (C0 &x, int i)
+{
+ if (x.i0 != i)
+ abort ();
+}
+
+void check_C1 (C1 &x, int i)
+{
+ if (x.i1 != i)
+ abort ();
+}
+
+void check_C2 (C2 &x, int i)
+{
+ if (x.i2 != i)
+ abort ();
+}
+
+void check_C3 (C3 &x, int i)
+{
+ if (x.i3 != i)
+ abort ();
+}
+
+void check_C4 (C4 &x, int i)
+{
+ if (x.i4 != i)
+ abort ();
+}
+
+void check_C5 (C5 &x, int i)
+{
+ if (x.i5 != i)
+ abort ();
+}
+
+void check_C6 (C6 &x, int i)
+{
+ if (x.i6 != i)
+ abort ();
+}
+
+void check_C7 (C7 &x, int i)
+{
+ if (x.i7 != i)
+ abort ();
+}
+
+void check_C8 (C8 &x, int i)
+{
+ if (x.i8 != i)
+ abort ();
+}
+
+void check_C9 (C9 &x, int i)
+{
+ if (x.i9 != i)
+ abort ();
+}
--- /dev/null
+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.
--- /dev/null
+struct A {
+ virtual void f();
+ int f1 : 1;
+};
+
+struct B : public A {
+ int f2 : 1;
+ int : 0;
+ int f3 : 4;
+ int f4 : 3;
+};
--- /dev/null
+// 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 ();
+}
--- /dev/null
+#include "bitfield5.h"
+
+extern void bitfield5_y (B&);
+
+void bitfield5_x ()
+{
+ B b;
+
+ b.f3 = 7;
+ b.f4 = 3;
+
+ bitfield5_y (b);
+}
--- /dev/null
+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 ();
+}
--- /dev/null
+union U {
+ int i: 4096;
+};
--- /dev/null
+// { 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 ();
+}
--- /dev/null
+#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);
+}
--- /dev/null
+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 ();
+}
--- /dev/null
+struct A {};
+
+struct B {
+ A a;
+ virtual void f () {}
+ int i;
+};
--- /dev/null
+// `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 ();
+}
--- /dev/null
+#include "empty6.h"
+
+extern void empty6_y (B&);
+
+void empty6_x ()
+{
+ B b;
+
+ b.i = 7;
+
+ empty6_y (b);
+}
--- /dev/null
+extern "C" void abort (void);
+
+#include "empty6.h"
+
+void empty6_y (B& b)
+{
+ if (b.i != 7)
+ abort ();
+}
--- /dev/null
+struct A {
+ virtual void f();
+ char c1;
+};
+
+struct B {
+ B();
+ char c2;
+};
+
+struct C : public A, public virtual B {
+};
--- /dev/null
+// 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 ();
+}
--- /dev/null
+#include "vbase10.h"
+
+extern void vbase10_y (C&);
+
+void vbase10_x ()
+{
+ C c;
+
+ c.c1 = 1;
+ c.c2 = 2;
+
+ vbase10_y (c);
+}
--- /dev/null
+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 ();
+}
--- /dev/null
+struct base
+{
+ short b;
+ virtual int foo();
+};
+
+struct derived: virtual base
+{
+ int d;
+ virtual int foo();
+ virtual int bar();
+};
--- /dev/null
+// 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 ();
+}
--- /dev/null
+#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);
+}
--- /dev/null
+extern "C" void abort (void);
+
+#include "vbase11.h"
+
+void vbase11_y (derived& d)
+{
+ if (d.foo() != 2)
+ abort ();
+ if (d.bar() != 3)
+ abort ();
+}
--- /dev/null
+# Copyright (C) 2002 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#
+# This file was written by Janis Johnson, <janis187@us.ibm.com>
+
+
+# Test interoperability of two compilers that follow the same ABI.
+#
+# Break simple tests into two pieces and see that they work when linked
+# together. If an alternate compiler is specified then the two main
+# pieces of each test are compiled with different compilers. The
+# alternate compiler must be installed, and is specified by defining
+# ALT_CXX_UNDER_TEST in the environment.
+
+if $tracelevel then {
+ strace $tracelevel
+}
+
+global GXX_UNDER_TEST
+global ld_library_path
+
+# Load procedures from common libraries.
+load_lib standard.exp
+load_lib g++.exp
+
+#
+# compat-fix-library-path -- switch LD_LIBRARY_PATH
+#
+proc compat-fix-library-path { } {
+ global ld_library_path
+
+ # See comments in lib/g++.exp for why this is needed.
+ setenv LD_LIBRARY_PATH $ld_library_path
+ setenv SHLIB_PATH $ld_library_path
+ setenv LD_LIBRARYN32_PATH $ld_library_path
+ setenv LD_LIBRARY64_PATH $ld_library_path
+}
+
+#
+# compat-use-alt-compiler -- make the alternate compiler the default
+#
+proc compat-use-alt-compiler { } {
+ global GXX_UNDER_TEST ALT_CXX_UNDER_TEST
+ global CXXFLAGS
+ global ALWAYS_CXXFLAGS
+ global ld_library_path alt_ld_library_path
+ global same_alt
+
+ # We don't need to do this if the alternate compiler is actually
+ # the same as the compiler under test.
+ if { $same_alt == 0 } then {
+ set GXX_UNDER_TEST $ALT_CXX_UNDER_TEST
+ set CXXFLAGS ""
+ set ALWAYS_CXXFLAGS ""
+ set ld_library_path $alt_ld_library_path
+ compat-fix-library-path
+ }
+}
+
+#
+# compat-use-tst-compiler -- make compiler under test the default
+#
+proc compat-use-tst-compiler { } {
+ global GXX_UNDER_TEST save_gxx_under_test
+ global CXXFLAGS save_cxxflags
+ global ALWAYS_CXXFLAGS save_always_cxxflags
+ global ld_library_path save_ld_library_path
+ global same_alt
+
+ # We don't need to do this if the alternate compiler is actually
+ # the same as the compiler under test.
+
+ if { $same_alt == 0 } then {
+ set GXX_UNDER_TEST $save_gxx_under_test
+ set CXXFLAGS $save_cxxflags
+ set ALWAYS_CXXFLAGS $save_always_cxxflags
+ set ld_library_path $save_ld_library_path
+ compat-fix-library-path
+ }
+}
+
+# Load the language-independent compabibility support procedures.
+# This must be done after the compat-use-*-compiler definitions.
+load_lib compat.exp
+
+g++_init
+
+# Save variables for the C++ compiler under test, which each test will
+# change a couple of times. This must be done after calling g++-init.
+set save_gxx_under_test $GXX_UNDER_TEST
+set save_cxxflags $CXXFLAGS
+set save_always_cxxflags $ALWAYS_CXXFLAGS
+set save_ld_library_path $ld_library_path
+
+# Find out whether there is an alternate compiler to test. If the
+# variable is defined but is set to "same", that means we use the same
+# compiler twice, which is meaningful if the two parts of COMPAT_OPTIONS
+# are different.
+set use_alt 0
+set same_alt 0
+set alt_ld_library_path "."
+if [info exists ALT_CXX_UNDER_TEST] then {
+ set use_alt 1
+ if [string match "same" $ALT_CXX_UNDER_TEST] then {
+ set same_alt 1
+ } else {
+ if [info exists ALT_LD_LIBRARY_PATH] then {
+ append alt_ld_library_path ":${ALT_LD_LIBRARY_PATH}"
+ }
+ }
+}
+
+# Main loop.
+foreach src [lsort [find $srcdir/$subdir *_main.C]] {
+ # If we're only testing specific files and this isn't one of them, skip it.
+ if ![runtest_file_p $runtests $src] then {
+ continue
+ }
+
+ compat-execute $src $use_alt
+}
+
+# Restore the original compiler under test.
+compat-use-tst-compiler
--- /dev/null
+struct Foo
+{
+ ~Foo ();
+};
+
+struct Bar
+{
+ ~Bar ();
+ Foo f;
+};
--- /dev/null
+// Copyright (C) 2001 Free Software Foundation, Inc.
+// Contributed by Nathan Sidwell 26 Dec 2001 <nathan@nathan@codesourcery.com>
+// PR 411
+
+// Split into pieces for binary compatibility testing October 2002
+
+extern void ctor1_x (void);
+
+int
+main ()
+{
+ ctor1_x ();
+}
--- /dev/null
+extern "C" void abort (void);
+extern "C" void exit (int);
+
+#include "ctor1.h"
+
+bool was_f_in_Bar_destroyed=false;
+
+void ctor1_x ()
+{
+ try
+ {
+ Bar f;
+ }
+ catch(int i)
+ {
+ if(was_f_in_Bar_destroyed)
+ {
+ exit (0);
+ }
+ }
+ abort ();
+}
--- /dev/null
+extern bool was_f_in_Bar_destroyed;
+
+#include "ctor1.h"
+
+Foo::~Foo()
+{
+ was_f_in_Bar_destroyed=true;
+}
+
+Bar::~Bar()
+{
+ throw 1;
+}
--- /dev/null
+struct VBase
+{
+ virtual void f () {}
+ VBase();
+ ~VBase();
+};
+
+struct StreamBase
+{
+ virtual ~StreamBase() {}
+};
+
+struct Stream : public virtual VBase, public StreamBase
+{
+ Stream();
+ virtual ~Stream() {}
+};
+
+struct DerivedStream : public Stream
+{
+ DerivedStream();
+};
--- /dev/null
+// PR c++/4460
+// Test that the cleanup for fully-constructed subobjects when a
+// constructor throws gets the right address for a virtual base.
+
+// Split into pieces for binary compatibility testing October 2002
+
+extern void ctor2_x (void);
+
+int main ()
+{
+ ctor2_x ();
+}
--- /dev/null
+extern "C" void exit (int);
+extern "C" void abort (void);
+
+#include "ctor2.h"
+
+int r;
+
+void ctor2_x () {
+
+ try
+ {
+ DerivedStream str;
+ }
+ catch (...) { }
+
+ if (r != 0)
+ abort ();
+ exit (0);
+}
--- /dev/null
+extern int r;
+void *p;
+
+#include "ctor2.h"
+
+VBase::VBase ()
+{
+ p = this;
+}
+
+VBase::~VBase ()
+{
+ if (p != this) r = 1;
+}
+
+Stream::Stream () {}
+DerivedStream::DerivedStream ()
+{
+ throw 1;
+}
--- /dev/null
+struct A {
+ ~A();
+};
+
+struct B: public A {
+ ~B();
+};
--- /dev/null
+// PR c++/411
+
+// Test that a fully-constructed base is destroyed before transferring
+// control to the handler of a function-try-block.
+
+// Split into pieces for binary compatibility testing October 2002
+
+extern void dtor1_x (void);
+
+int
+main ()
+{
+ dtor1_x ();
+}
--- /dev/null
+extern "C" void exit (int);
+extern "C" void abort (void);
+
+#include "dtor1.h"
+
+int r;
+
+void dtor1_x ()
+{
+ { B b; }
+ if (r != 0)
+ abort ();
+ exit (0);
+}
--- /dev/null
+extern int r;
+int ad;
+
+#include "dtor1.h"
+
+A::~A () { ++ad; }
+
+B::~B ()
+try
+ {
+ throw 1;
+ }
+catch (...)
+ {
+ if (!ad)
+ r = 1;
+ return;
+ }
--- /dev/null
+struct a
+{
+ a();
+ ~a();
+};
--- /dev/null
+// Test that cleanups get run when a catch filter fails to match.
+
+// Split into pieces for binary compatibility testing October 2002
+
+extern void filter1_x (void);
+
+int
+main ()
+{
+ filter1_x ();
+}
--- /dev/null
+#include "filter1.h"
+
+extern "C" void exit (int);
+extern "C" void abort (void);
+extern void ex_test (void);
+
+void
+filter1_x ()
+{
+ try
+ {
+ ex_test ();
+ }
+ catch (...)
+ {
+ }
+ abort ();
+}
+
+a::a() { }
+a::~a() { exit (0); }
--- /dev/null
+#include "filter1.h"
+
+struct e1 {};
+struct e2 {};
+
+void
+ex_test ()
+{
+ a aa;
+ try
+ {
+ throw e1 ();
+ }
+ catch (e2 &)
+ {
+ }
+}
--- /dev/null
+// Test that terminate gets run when a catch filter fails to match while
+// running destructors. Original bug depended on a::~a being inlined.
+
+// Split into pieces for binary compatibility testing October 2002
+
+extern void filter2_x (void);
+
+int
+main ()
+{
+ filter2_x ();
+}
--- /dev/null
+#include <exception>
+#include <cstdlib>
+
+extern void my_terminate (void);
+extern void ex_test (void);
+
+void
+filter2_x ()
+{
+ std::set_terminate (my_terminate);
+
+ try
+ {
+ ex_test ();
+ }
+ catch (...)
+ {
+ }
+ abort ();
+}
--- /dev/null
+#include <exception>
+#include <cstdlib>
+
+struct e1 {};
+struct e2 {};
+
+struct a
+{
+ a () { }
+
+ ~a ()
+ {
+ try
+ {
+ throw e1();
+ }
+ catch (e2 &)
+ {
+ }
+ }
+};
+
+void
+ex_test ()
+{
+ a aa;
+ try
+ {
+ throw e1 ();
+ }
+ catch (e2 &)
+ {
+ }
+}
+
+void my_terminate ()
+{
+ std::exit (0);
+}
--- /dev/null
+// PR c++/5757
+// Test that when a constructor throws in a new-expression, we pass the
+// right pointer to operator delete.
+
+// Split into pieces for binary compatibility testing October 2002
+
+extern void new1_x (void);
+
+int
+main ()
+{
+ new1_x ();
+}
--- /dev/null
+#include <new>
+
+extern "C" void exit (int);
+extern "C" void abort (void);
+
+extern void * operator new[] (size_t s) throw (std::bad_alloc);
+extern void operator delete[] (void *p) throw ();
+
+struct A
+{
+ A() { throw 1; }
+ ~A() {}
+};
+
+int ret = 1;
+
+void
+new1_x ()
+{
+ try
+ {
+ A *p = new A[4];
+ }
+ catch (...) {}
+ if (ret != 0)
+ abort ();
+ exit (0);
+}
--- /dev/null
+#include <new>
+
+extern int ret;
+
+void *ptr;
+void * operator new[] (size_t s) throw (std::bad_alloc)
+{
+ ptr = operator new (s);
+ return ptr;
+}
+
+void operator delete[] (void *p) throw ()
+{
+ if (p == ptr)
+ ret = 0;
+ operator delete (p);
+}
+
--- /dev/null
+struct A
+{
+ A();
+ ~A();
+};
--- /dev/null
+// PR c++/5636
+// Bug: the named return value optimization interfered with EH cleanups.
+
+// Split into pieces for binary compatibility testing October 2002
+
+extern void nrv1_x (void);
+
+int
+main ()
+{
+ nrv1_x ();
+}
--- /dev/null
+extern "C" void exit (int);
+extern "C" void abort (void);
+
+#include "nrv1.h"
+
+extern A f (void);
+
+int c, d;
+
+void nrv1_x ()
+{
+ try
+ { A a = f(); }
+ catch (...) { }
+ if (d < c)
+ abort ();
+ exit (0);
+}
+
+A::A() { ++c; }
+A::~A() { ++d; }
--- /dev/null
+#include "nrv1.h"
+
+A f()
+{
+ A nrv;
+ throw 42;
+ return nrv;
+}
--- /dev/null
+class Base {};
+
+struct A : virtual public Base
+{
+ A();
+};
+
+struct B {};
--- /dev/null
+// PR c++/4381
+// Test that exception-specs work properly for classes with virtual bases.
+
+// Split into pieces for binary compatibility testing October 2002
+
+extern void spec3_x (void);
+
+int
+main ()
+{
+ spec3_x ();
+}
--- /dev/null
+#include "spec3.h"
+
+extern void func () throw (B,A);
+
+void spec3_x (void)
+{
+ try { func(); }
+ catch (A& a) { }
+}
--- /dev/null
+#include "spec3.h"
+
+A::A() {}
+
+void func() throw (B,A)
+{
+ throw A();
+}
--- /dev/null
+class A {};
+
+template <class T>
+struct B
+{
+ typedef A E;
+};
+
+template <class T>
+struct C
+{
+ typedef B<T> D;
+ typedef typename D::E E;
+ void f() throw(E);
+};
--- /dev/null
+// Test whether exception specifier dependent on template parameter
+// is accepted during template decl processing.
+
+// Split into pieces for binary compatibility testing October 2002
+
+extern void template1_x (void);
+
+int
+main ()
+{
+ template1_x ();
+}
--- /dev/null
+extern "C" void exit (int);
+extern "C" void abort (void);
+
+#include "template1.h"
+
+void template1_x ()
+{
+ int caught = 0;
+ try
+ {
+ C<int> x;
+ x.f();
+ }
+ catch (A)
+ {
+ ++caught;
+ }
+ if (caught != 1)
+ abort ();
+ exit (0);
+}
--- /dev/null
+#include "template1.h"
+
+template<class T> void C<T>::f (void) throw (E)
+{
+ throw E();
+}
+
+template class C<int>;
--- /dev/null
+// PR 3719
+// Test that an unexpected handler can rethrow to categorize.
+
+// Split into pieces for binary compatibility testing October 2002
+
+extern void unexpected1_x ();
+
+int
+main ()
+{
+ unexpected1_x ();
+}
--- /dev/null
+#include <exception>
+
+struct One { };
+struct Two { };
+
+extern "C" void abort ();
+extern void doit (void) throw (Two);
+extern void handle_unexpected (void);
+
+void
+unexpected1_x ()
+{
+ std::set_unexpected (handle_unexpected);
+
+ try
+ {
+ doit ();
+ }
+ catch (Two &)
+ {
+ }
+ catch (...)
+ {
+ abort ();
+ }
+}
--- /dev/null
+struct One { };
+struct Two { };
+
+void
+handle_unexpected ()
+{
+ try
+ {
+ throw;
+ }
+ catch (One &)
+ {
+ throw Two ();
+ }
+}
+
+void
+doit () throw (Two)
+{
+ throw One ();
+}
--- /dev/null
+// Copyright (C) 2002 Free Software Foundation
+// Contributed by Kriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net>
+// Split into pieces for binary compatibility testing October 2002
+
+// Incorrect construction and destruction of multi-dimensional
+// array of class.
+
+extern void array5_x (void);
+
+int
+main ()
+{
+ array5_x ();
+}
--- /dev/null
+extern "C" void abort (void);
+
+extern int count;
+extern int num;
+
+struct A
+{
+ A();
+ ~A();
+};
+
+struct Array
+{
+ A array[2][2][2];
+};
+
+void
+array5_x ()
+{
+ for (num = 0; num <= 8; ++num)
+ {
+ count = 0;
+ try
+ {
+ Array A;
+ }
+ catch (...)
+ {
+ }
+ if (count != 0)
+ abort();
+ }
+}
--- /dev/null
+int count;
+int num;
+
+struct A
+{
+ A();
+ ~A();
+};
+
+A::A()
+{
+ if (count == num)
+ throw "";
+ count++;
+}
+
+A::~A()
+{
+ count--;
+}
--- /dev/null
+struct C
+{
+ int m;
+ C();
+ ~C();
+};
--- /dev/null
+// PR c++/3948
+// Test that the destructor call for a value parameter gets the
+// right address.
+// Split into pieces for binary compatibility testing October 2002
+
+extern void byval1_x (void);
+
+int
+main ()
+{
+ byval1_x ();
+}
--- /dev/null
+#include "byval1.h"
+
+extern "C" void abort (void);
+extern void Foo (C c);
+extern int r;
+
+void
+byval1_x ()
+{
+ C c;
+
+ Foo (c);
+ if (r != 0)
+ abort ();
+}
--- /dev/null
+#include "byval1.h"
+
+void *p[2];
+
+int i;
+int r;
+
+C::C() { p[i++] = this; }
+C::~C() { if (p[--i] != this) r = 1; }
+
+void Foo (C c)
+{
+ p[i++] = &c;
+}
--- /dev/null
+struct B
+{
+ int x;
+ B (int);
+ ~B ();
+};
+
+struct C1 : public B {
+ C1 (int);
+};
+
+struct C2 : public B {
+ C2 (int);
+};
+
+struct D : public B {
+ D (int);
+};
+
+struct E : public B {
+ E (int);
+};
+
+struct A
+ : public C1, C2, virtual public D, virtual public E
+{
+ A ();
+ B x1;
+ B x2;
+};
--- /dev/null
+// Split into pieces for binary compatibility testing October 2002
+
+extern void dtor1_x (void);
+
+int
+main ()
+{
+ dtor1_x ();
+}
--- /dev/null
+#include "dtor1.h"
+
+void
+dtor1_x (void)
+{
+ A a;
+}
--- /dev/null
+#include "dtor1.h"
+
+extern "C" void abort ();
+
+int d = 5;
+
+B::B (int i) : x (i) { }
+B::~B () { if (d-- != x) abort (); }
+
+C1::C1 (int i) : B (i) {}
+
+C2::C2 (int i) : B (i) {}
+
+D::D (int i) : B (i) {}
+
+E::E (int i) : B (i) {}
+
+A::A () : D (0), E (1), C1 (2), C2 (3), x1(4), x2(5) {}
--- /dev/null
+struct A {
+ A ();
+ A (const A&);
+ ~A ();
+};
--- /dev/null
+// Test that the destructor for a temporary passed by value isn't run
+// until end of full-expression, as per [class.copy]:
+
+// Whenever a temporary class object is copied using a copy constructor,
+// and this object and the copy have the same cv-unqualified type, an
+// implementation is permitted to treat the original and the copy as two
+// different ways of referring to the same object and not perform a copy
+// at all, even if the class copy constructor or destructor have side
+// effects.... In these cases, the
+// object is destroyed at the later of times when the original and the
+// copy would have been destroyed without the optimization.
+
+// Here, the temporary would be destroyed later than the parm, so either we
+// must suppress the optimization in this case or destroy value parms in the
+// caller.
+
+// Split into pieces for binary compatibility testing October 2002
+
+extern void elide1_x (void);
+
+int
+main ()
+{
+ elide1_x ();
+}
--- /dev/null
+#include "elide1.h"
+
+extern "C" void abort (void);
+extern void f (A);
+extern int d;
+
+void
+elide1_x (void)
+{
+ int r;
+ f (A ()), r = d;
+
+ if (r >= d || !d)
+ abort ();
+}
--- /dev/null
+#include "elide1.h"
+
+int d;
+
+A::A () { }
+A::A (const A&) { }
+A::~A() { ++d; }
+
+void f (A a) { }
--- /dev/null
+// Submitted by Jason Merrill <jason_merrill@redhat.com>
+// Test for proper handling of local static references.
+// Split into pieces for binary compatibility testing October 2002
+
+extern void init_ref2_x (void);
+
+int
+main ()
+{
+ init_ref2_x ();
+}
--- /dev/null
+extern "C" void abort (void);
+extern void g (void);
+extern void h (void);
+
+int r;
+int c;
+int f ()
+{
+ // Test that we only initialize i once.
+ if (++c > 1)
+ ++r;
+ return 42;
+}
+
+void
+init_ref2_x (void)
+{
+ g ();
+ h ();
+ if (r != 0)
+ abort ();
+}
--- /dev/null
+extern int f (void);
+extern int r;
+
+const int *p;
+
+void g ()
+{
+ static const int &i = f();
+
+ // Test that i points to the same place in both calls.
+ if (p && p != &i)
+ ++r;
+ // Test that if so, it points to static data.
+ if (i != 42)
+ ++r;
+
+ p = &i;
+}
+
+void h ()
+{
+ int arr[] = { 1, 1, 1, 1, 1, 1, 1 };
+ g ();
+}
# that are handled specially.
set tests [lsort [find $srcdir/$subdir *.C]]
set tests [prune $tests $srcdir/$subdir/bprob/*]
+set tests [prune $tests $srcdir/$subdir/compat/*]
set tests [prune $tests $srcdir/$subdir/debug/*]
set tests [prune $tests $srcdir/$subdir/gcov/*]
set tests [prune $tests $srcdir/$subdir/special/*]
--- /dev/null
+# Copyright (C) 2002 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+# This file was written by Janis Johnson, <janis187@us.ibm.com>
+
+
+# Test interoperability of two compilers that follow the same ABI, or
+# compatibility of two versions of GCC.
+#
+# Each test has a main program that does nothing but call a function,
+# plus two additional source files that contain parts of a program that
+# rely on the ABI. those source files are compiled into relocatable
+# object files with both compilers. Executables are built using various
+# combinations of those object files, with the main program compiled
+# with the compiler under test and using that compiler's runtime support.
+
+# The including .exp file must define these callback procedures.
+if [string match "" [info procs "compat-use-alt-compiler"]] then {
+ error "Proc compat-use-alt-compiler is not defined."
+}
+if [string match "" [info procs "compat-use-tst-compiler"]] then {
+ error "Proc compat-use-tst-compiler is not defined."
+}
+
+# Each test is run with each pair of compiler options from this list.
+# The first set of options in each pair is used by the compiler under
+# test, and the second set is used by the alternate compiler.
+# The default option lists can be overridden by
+# COMPAT_OPTIONS="[list [list {tst_1} {alt_1}]...[list {tst_n} {alt_n}]]"
+# where tst_i and alt_i are lists of options. You can put this in the
+# environment before site.exp is written or add it to site.exp directly.
+if ![info exists COMPAT_OPTIONS] {
+ set COMPAT_OPTIONS [list \
+ [list {} {}]]
+}
+
+set option_list $COMPAT_OPTIONS
+
+#
+# compat-obj -- compile to an object file
+#
+# SOURCE is the source file
+# DEST is the object file
+# OPTIONS is the list of compiler options
+# OPTSTR is the options to print with test messages
+#
+proc compat-obj { source dest options optstr } {
+ global testcase
+ global tool
+
+ set comp_output [${tool}_target_compile "$source" "$dest" object $options]
+ ${tool}_check_compile "$testcase $dest compile" $optstr $dest $comp_output
+}
+
+# compat-run -- link and run an executable
+#
+# TESTNAME is the mixture of object files to link
+# OBJLIST is the list of object files to link
+# DEST is the name of the executable
+# OPTIONS is a list of compiler and linker options to use
+# OPTSTR is the list of options to list in messages
+#
+proc compat-run { testname objlist dest options optstr } {
+ global testcase
+ global tool
+
+ # Check that all of the objects were built successfully.
+ foreach obj [split $objlist] {
+ if ![file exists $obj] then {
+ unresolved "$testcase $testname link $optstr"
+ unresolved "$testcase $testname execute $optstr"
+ return
+ }
+ }
+
+ # Link the objects into an executable.
+ set comp_output [${tool}_target_compile "$objlist" $dest executable \
+ "$options"]
+ if ![${tool}_check_compile "$testcase $testname link" "" \
+ $dest $comp_output] then {
+ unresolved "$testcase $testname execute $optstr"
+ return
+ }
+
+ # Run the self-checking executable.
+ set result [${tool}_load $dest "" ""]
+ set status [lindex $result 0]
+ if { $status == "pass" } then {
+ remote_file build delete $dest
+ }
+ $status "$testcase $testname execute $optstr"
+}
+
+#
+# compat-execute -- compile with compatible compilers
+#
+# SRC1 is the full pathname of the main file of the testcase.
+# USE_ALT is nonzero if we're using an alternate compiler as well as
+# the compiler under test.
+#
+proc compat-execute { src1 use_alt } {
+ global srcdir tmpdir
+ global option_list
+ global tool
+ global verbose
+ global testcase
+
+ # Use the dg-options mechanism to specify extra flags for this test.
+ # FIXME: This does not handle other uses of dg-options, and it only
+ # processes the first one.
+ set extra_tool_flags ""
+ set tmp [grep $src1 "{\[ \t\]\*dg-options.*\[ \t\]\+}"]
+ if ![string match "" $tmp] {
+ set tmp0 [lindex $tmp 0]
+ # Extract the compiler options.
+ regexp "dg-options\[ \t\]\+(.*)\[ \t\]\+\}" \
+ $tmp0 all args
+ # Sometime the options are in quotes, sometimes not.
+ regsub -all "\"" $args "" args
+ set extra_tool_flags $args
+ }
+
+ # Set up the names of the other source files.
+ regsub "_main.*" $src1 "" base
+ regsub ".*/" $base "" base
+ regsub "_main" $src1 "_x" src2
+ regsub "_main" $src1 "_y" src3
+
+ # Define the names of the object files.
+ set obj1 "main_tst.o"
+ set obj2_tst "x_tst.o"
+ set obj2_alt "x_alt.o"
+ set obj3_tst "y_tst.o"
+ set obj3_alt "y_alt.o"
+
+ # Get the base name of this test, for use in messages.
+ regsub "^$srcdir/?" $src1 "" testcase
+ regsub "_main.*" $testcase "" testcase
+ # Set up the base name of executable files so they'll be unique.
+ regsub -all "\[./\]" $testcase "-" execbase
+
+ # If we couldn't rip $srcdir out of `src1' then just do the best we can.
+ # The point is to reduce the unnecessary noise in the logs. Don't strip
+ # out too much because different testcases with the same name can confuse
+ # `test-tool'.
+ if [string match "/*" $testcase] then {
+ set testcase "[file tail [file dirname $src1]]/[file tail $src1]"
+ }
+
+ # Loop through all of the option lists used for this test.
+
+ set count 0
+ foreach option_pair $option_list {
+
+ # Pick out each set of options.
+ set tst_option [lindex $option_pair 0]
+ set alt_option [lindex $option_pair 1]
+ set optstr ""
+ if { ![string match $tst_option ""] \
+ || ![string match $alt_option ""] } then {
+ set optstr "\"$tst_option\",\"$alt_option\""
+ }
+ verbose "Testing $testcase, $optstr" 1
+
+ set tst_options ""
+ set alt_options ""
+ if ![string match $extra_tool_flags ""] then {
+ lappend tst_options "additional_flags=$extra_tool_flags $tst_option"
+ lappend alt_options "additional_flags=$extra_tool_flags $alt_option"
+ }
+
+ # There's a unique name for each executable we generate, based on
+ # the set of options and how the pieces of the tests are compiled.
+ set execname1 "${execbase}-${count}1"
+ set execname2 "${execbase}-${count}2"
+ set execname3 "${execbase}-${count}3"
+ set execname4 "${execbase}-${count}4"
+ incr count
+
+ remote_file build delete $execname1
+ remote_file build delete $execname2
+ remote_file build delete $execname3
+ remote_file build delete $execname4
+
+ # Compile pieces with the alternate compiler; we'll catch problems
+ # later. Skip this if we don't have an alternate compiler.
+ if { $use_alt != 0 } then {
+ compat-use-alt-compiler
+ compat-obj "$src2" "$obj2_alt" $alt_options $optstr
+ compat-obj "$src3" "$obj3_alt" $alt_options $optstr
+ }
+
+ # Compile pieces with the compiler under test.
+ compat-use-tst-compiler
+ compat-obj "$src1" "$obj1" $tst_options $optstr
+ compat-obj "$src2" "$obj2_tst" $tst_options $optstr
+ compat-obj "$src3" "$obj3_tst" $tst_options $optstr
+
+ # Link (using the compiler under test), run, and clean up tests.
+ compat-run "${obj2_tst}-${obj3_tst}" \
+ "$obj1 $obj2_tst $obj3_tst" $execname1 $tst_options $optstr
+
+ # If we've got an alternate compiler try some combinations.
+ if { $use_alt != 0 } then {
+ compat-run "${obj2_tst}-${obj3_alt}" "$obj1 $obj2_tst $obj3_alt" \
+ $execname2 $tst_options $optstr
+ compat-run "${obj2_alt}-${obj3_tst}" "$obj1 $obj2_alt $obj3_tst" \
+ $execname3 $tst_options $optstr
+ compat-run "${obj2_alt}-${obj3_alt}" "$obj1 $obj2_alt $obj3_alt" \
+ $execname4 $tst_options $optstr
+ }
+
+ # Clean up object files.
+ set files [glob -nocomplain *.o]
+ if { $files != "" } {
+ eval "remote_file build delete $files"
+ }
+ }
+}