aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/gcc.c-torture/execute/nest-align-1.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc-4.9/gcc/testsuite/gcc.c-torture/execute/nest-align-1.c')
-rw-r--r--gcc-4.9/gcc/testsuite/gcc.c-torture/execute/nest-align-1.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/gcc-4.9/gcc/testsuite/gcc.c-torture/execute/nest-align-1.c b/gcc-4.9/gcc/testsuite/gcc.c-torture/execute/nest-align-1.c
new file mode 100644
index 000000000..548c8878d
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/gcc.c-torture/execute/nest-align-1.c
@@ -0,0 +1,40 @@
+/* Test for alignment handling when a variable is accessed by nested
+ function. */
+/* Origin: Joey Ye <joey.ye@intel.com> */
+
+#include <stddef.h>
+
+typedef int aligned __attribute__((aligned));
+extern void abort (void);
+
+void
+check (int *i)
+{
+ *i = 20;
+ if ((((ptrdiff_t) i) & (__alignof__(aligned) - 1)) != 0)
+ abort ();
+}
+
+void
+foo (void)
+{
+ aligned jj;
+ void bar ()
+ {
+ jj = -20;
+ }
+ jj = 0;
+ bar ();
+ if (jj != -20)
+ abort ();
+ check (&jj);
+ if (jj != 20)
+ abort ();
+}
+
+int
+main()
+{
+ foo ();
+ return 0;
+}