OSDN Git Service

test case for alignment bug in packed structs for STRICT_ALIGNMENT targets
authorchrbr <chrbr@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 19 Feb 2008 07:42:25 +0000 (07:42 +0000)
committerchrbr <chrbr@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 19 Feb 2008 07:42:25 +0000 (07:42 +0000)
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@132415 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/packed-array.c [new file with mode: 0644]

index db65ae6..425549d 100644 (file)
@@ -1,3 +1,7 @@
+2008-02-19  Christian Bruel  <christian.bruel@st.com>
+
+       * gcc.dg/packed-array.c: New testcase. 
+
 2008-02-19  Uros Bizjak  <ubizjak@gmail.com>
 
        PR target/33555
diff --git a/gcc/testsuite/gcc.dg/packed-array.c b/gcc/testsuite/gcc.dg/packed-array.c
new file mode 100644 (file)
index 0000000..b57f3ac
--- /dev/null
@@ -0,0 +1,40 @@
+/* { dg-do run } */
+/* { dg-options "-O2 -fno-inline" } */
+
+struct usb_interface_descriptor {
+ unsigned short wMaxPacketSize;
+  char e;
+} __attribute__ ((packed));
+
+struct usb_device {
+ int devnum;
+ struct usb_interface_descriptor if_desc[2];
+};
+
+extern int printf (const char *, ...);
+
+void foo (unsigned short a)
+{
+  printf ("%d\n", a);
+}
+
+struct usb_device ndev;
+
+void usb_set_maxpacket(int n)
+{
+  int i;
+
+  for(i=0; i<n;i++)
+    foo((&ndev)->if_desc[i].wMaxPacketSize);
+}
+
+int
+main()
+{
+  usb_set_maxpacket(2);
+  return 0;
+}
+
+
+
+