aboutsummaryrefslogtreecommitdiff
path: root/gcc/cil/tests/s1.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/cil/tests/s1.c')
-rw-r--r--gcc/cil/tests/s1.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/gcc/cil/tests/s1.c b/gcc/cil/tests/s1.c
new file mode 100644
index 00000000000..5b467399bd6
--- /dev/null
+++ b/gcc/cil/tests/s1.c
@@ -0,0 +1,40 @@
+/*
+ * This example tests operations on elements of type struct.
+ */
+#include <stdio.h>
+
+
+typedef struct {
+ int a;
+ long long d;
+} foo;
+
+static void
+p (foo *f)
+{
+ printf ("%d %lld\n", f->a, f->d);
+}
+
+int main()
+{
+ int one = 1;
+ int three = 3;
+ foo f[3] = {{one, 2}, {three, 4}, {5, 6}};
+
+ p(&f[0]);
+ p(&f[1]);
+ p(&f[2]);
+
+ /*printf ("&one = %p\n&three = %p\n&f = %p\n", &one, &three, &f);*/
+ printf ("sizeof (one) = %d\nsizeof (three) = %d\nsizeof (f) = %d\n", (int) sizeof (one), (int) sizeof (three), (int) sizeof (f));
+
+#if 0
+ f[0] = f[1];
+
+ p(&f[0]);
+ p(&f[1]);
+ p(&f[2]);
+#endif
+
+ return 10;
+}