summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.old-deja/g++.abi/aggregates.C
diff options
context:
space:
mode:
authorupstream source tree <ports@midipix.org>2015-03-15 20:14:05 -0400
committerupstream source tree <ports@midipix.org>2015-03-15 20:14:05 -0400
commit554fd8c5195424bdbcabf5de30fdc183aba391bd (patch)
tree976dc5ab7fddf506dadce60ae936f43f58787092 /gcc/testsuite/g++.old-deja/g++.abi/aggregates.C
downloadcbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.bz2
cbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.xz
obtained gcc-4.6.4.tar.bz2 from upstream website;upstream
verified gcc-4.6.4.tar.bz2.sig; imported gcc-4.6.4 source tree from verified upstream tarball. downloading a git-generated archive based on the 'upstream' tag should provide you with a source tree that is binary identical to the one extracted from the above tarball. if you have obtained the source via the command 'git clone', however, do note that line-endings of files in your working directory might differ from line-endings of the respective files in the upstream repository.
Diffstat (limited to 'gcc/testsuite/g++.old-deja/g++.abi/aggregates.C')
-rw-r--r--gcc/testsuite/g++.old-deja/g++.abi/aggregates.C126
1 files changed, 126 insertions, 0 deletions
diff --git a/gcc/testsuite/g++.old-deja/g++.abi/aggregates.C b/gcc/testsuite/g++.old-deja/g++.abi/aggregates.C
new file mode 100644
index 000000000..24f430bd6
--- /dev/null
+++ b/gcc/testsuite/g++.old-deja/g++.abi/aggregates.C
@@ -0,0 +1,126 @@
+// { dg-do run { target i?86-*-linux* x86_64-*-linux* i?86-*-freebsd* } }
+// { dg-require-effective-target ilp32 }
+// { dg-options "-malign-double" }
+// Origin: Alex Samuel <samuel@codesourcery.com>
+
+/* Test the data layout of C aggregates by checking aggregate size and
+ alignment and field offsets for compliance with the IA-64 ABI. */
+
+template<typename T>
+inline unsigned
+alignmentof ()
+{
+ struct S
+ {
+ char start_;
+ T object_;
+ };
+
+ return (unsigned) & ((S *) 0)->object_;
+}
+
+/* Computes the alignment, in bytes, of TYPE. */
+
+#define alignof(type) (alignmentof<type> ())
+
+/* Computes the offset of FIELD in AGGREGATE. */
+
+#define offsetof(aggregate, field) \
+ ((unsigned) (& ((aggregate*) 0)->field))
+
+
+/* Structs S1, S2, S3, S4, and union U5 are taken from Intel, "IA-64
+ Software Conventions and Runtime Architecture Guide", version of
+ August 1999. */
+
+struct S1
+{
+ char c;
+};
+
+struct S2
+{
+ char c;
+ char d;
+ short s;
+ int n;
+};
+
+struct S3
+{
+ char c;
+ short s;
+};
+
+struct S4
+{
+ char c;
+ double d;
+ short s;
+};
+
+union U5
+{
+ char c;
+ short s;
+ int j;
+};
+
+
+
+int
+main ()
+{
+ if (sizeof (struct S1) != 1)
+ return 1;
+ if (alignof (struct S1) != 1)
+ return 2;
+ if (offsetof (struct S1, c) != 0)
+ return 3;
+
+ if (sizeof (struct S2) != 8)
+ return 4;
+ if (alignof (struct S2) != 4)
+ return 5;
+ if (offsetof (struct S2, c) != 0)
+ return 6;
+ if (offsetof (struct S2, d) != 1)
+ return 7;
+ if (offsetof (struct S2, s) != 2)
+ return 8;
+ if (offsetof (struct S2, n) != 4)
+ return 9;
+
+ if (sizeof (struct S3) != 4)
+ return 10;
+ if (alignof (struct S3) != 2)
+ return 11;
+ if (offsetof (struct S3, c) != 0)
+ return 12;
+ if (offsetof (struct S3, s) != 2)
+ return 13;
+
+ if (sizeof (struct S4) != 24)
+ return 14;
+ if (alignof (struct S4) != 8)
+ return 15;
+ if (offsetof (struct S4, c) != 0)
+ return 16;
+ if (offsetof (struct S4, d) != 8)
+ return 17;
+ if (offsetof (struct S4, s) != 16)
+ return 18;
+
+ if (sizeof (union U5) != 4)
+ return 19;
+ if (alignof (union U5) != 4)
+ return 20;
+ if (offsetof (union U5, c) != 0)
+ return 21;
+ if (offsetof (union U5, s) != 0)
+ return 22;
+ if (offsetof (union U5, j) != 0)
+ return 23;
+
+ return 0;
+}