summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/torture/stackalign/vararg-1.c
diff options
context:
space:
mode:
authorbstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4>2008-07-31 13:10:52 +0000
committerbstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4>2008-07-31 13:10:52 +0000
commit777d46780c3e30ecc800f0a613d65562caea9abf (patch)
treeeffc283a6f03409b0c3e0e3e20c70c5ab627776d /gcc/testsuite/gcc.dg/torture/stackalign/vararg-1.c
parent4c65aab8b90fdd8ef4e2b77e33c7a821297f60e6 (diff)
downloadgcc-777d46780c3e30ecc800f0a613d65562caea9abf.tar.gz
2008-07-31 Basile Starynkevitch <basile@starynkevitch.net>
the yesterday's version failed to compile any simple C file. Fixed! MELT branch merged with trunk r138355 * gcc/passes.c: better order for basilys related passes. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/melt-branch@138403 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/testsuite/gcc.dg/torture/stackalign/vararg-1.c')
-rw-r--r--gcc/testsuite/gcc.dg/torture/stackalign/vararg-1.c59
1 files changed, 59 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/torture/stackalign/vararg-1.c b/gcc/testsuite/gcc.dg/torture/stackalign/vararg-1.c
new file mode 100644
index 00000000000..62b236522ec
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/stackalign/vararg-1.c
@@ -0,0 +1,59 @@
+/* { dg-do run } */
+
+#include <stdarg.h>
+#include "check.h"
+
+#ifndef ALIGNMENT
+#define ALIGNMENT 64
+#endif
+
+typedef int aligned __attribute__((aligned(ALIGNMENT)));
+
+int global;
+
+void
+bar (char *p, int size)
+{
+ __builtin_strncpy (p, "good", size);
+}
+
+void
+foo (const char *fmt, ...)
+{
+ va_list arg;
+ char *p;
+ aligned i;
+ int size;
+ double x;
+
+ va_start (arg, fmt);
+ size = va_arg (arg, int);
+ if (size != 5)
+ abort ();
+ p = __builtin_alloca (size + 1);
+
+ x = va_arg (arg, double);
+ if (x != 5.0)
+ abort ();
+
+ bar (p, size);
+ if (__builtin_strncmp (p, "good", size) != 0)
+ {
+#ifdef DEBUG
+ p[size] = '\0';
+ printf ("Failed: %s != good\n", p);
+#endif
+ abort ();
+ }
+
+ if (check_int (&i, __alignof__(i)) != i)
+ abort ();
+ va_end (arg);
+}
+
+int
+main()
+{
+ foo ("foo", 5, 5.0);
+ return 0;
+}