summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/pr41935.c
diff options
context:
space:
mode:
authorrus <rus@138bc75d-0d04-0410-961f-82ee72b054a4>2009-11-09 20:58:24 +0000
committerrus <rus@138bc75d-0d04-0410-961f-82ee72b054a4>2009-11-09 20:58:24 +0000
commit7f4db7c80779ecbc57d1146654daf0acfe18de66 (patch)
tree3af522a3b5e149c3fd498ecb1255994daae2129a /gcc/testsuite/gcc.dg/pr41935.c
parent611349f0ec42a37591db2cd02974a11a48d10edb (diff)
downloadgcc-profile-stdlib.tar.gz
merge from trunkprofile-stdlib
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/profile-stdlib@154052 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/testsuite/gcc.dg/pr41935.c')
-rw-r--r--gcc/testsuite/gcc.dg/pr41935.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/pr41935.c b/gcc/testsuite/gcc.dg/pr41935.c
new file mode 100644
index 00000000000..e6a1b28670a
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr41935.c
@@ -0,0 +1,25 @@
+/* PR middle-end/41935 */
+/* { dg-do run } */
+/* { dg-options "-O2" } */
+
+extern void abort (void);
+struct A { int a; int b[10]; };
+
+int
+foo (struct A *p)
+{
+ return __builtin_offsetof (struct A, b[p->a]);
+}
+
+int
+main ()
+{
+ struct A a;
+ a.a = 7;
+ if (foo (&a) != 7 * sizeof (int) + __builtin_offsetof (struct A, b))
+ abort ();
+ a.a = 2;
+ if (foo (&a) != 2 * sizeof (int) + __builtin_offsetof (struct A, b))
+ abort ();
+ return 0;
+}