[llvm-commits] [test-suite] r69338 - /test-suite/trunk/SingleSource/UnitTests/2009-04-16-BitfieldInitialization.c

Chris Lattner sabre at nondot.org
Thu Apr 16 17:57:21 PDT 2009


Author: lattner
Date: Thu Apr 16 19:57:21 2009
New Revision: 69338

URL: http://llvm.org/viewvc/llvm-project?rev=69338&view=rev
Log:
new testcase for PR3510

Added:
    test-suite/trunk/SingleSource/UnitTests/2009-04-16-BitfieldInitialization.c

Added: test-suite/trunk/SingleSource/UnitTests/2009-04-16-BitfieldInitialization.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/UnitTests/2009-04-16-BitfieldInitialization.c?rev=69338&view=auto

==============================================================================
--- test-suite/trunk/SingleSource/UnitTests/2009-04-16-BitfieldInitialization.c (added)
+++ test-suite/trunk/SingleSource/UnitTests/2009-04-16-BitfieldInitialization.c Thu Apr 16 19:57:21 2009
@@ -0,0 +1,76 @@
+// PR3510
+
+struct ty { 
+  int info;
+  union {
+    int id;
+    char *str;
+  } u;
+} t1  = { 101,  1 };
+
+struct ty2 { 
+  float info __attribute__((packed));
+  char x;
+  int Y __attribute__((packed));
+} __attribute__((packed)) t2  = { 101,  1, 204 };
+
+struct ty3 { int A; char C[]; } t3 = { 4, "fo" };
+
+struct ty4 { 
+  long double x __attribute__((packed));
+  char y;
+  long double z __attribute__((packed));
+} __attribute__((packed)) t4  = { 1.0,  4, 17.0 };
+
+
+struct { 
+  char x;
+  unsigned char y : 4;
+} __attribute__((packed)) t5a  = { 101,  15 };
+
+struct { 
+  char x;
+  unsigned short y : 12;
+} __attribute__((packed)) t5b  = { 101,  1231 };
+
+struct { 
+  char x;
+  unsigned char y : 4;
+  unsigned char z : 7;
+} __attribute__((packed)) t5  = { 101,  15, 123 };
+
+
+struct { 
+  long double x;
+  unsigned char y : 4;
+} __attribute__((packed)) t6  = { 123.412,  5 };
+
+struct { 
+  char x;
+  unsigned char y : 4;
+  unsigned char q : 3;
+  unsigned char z : 7;
+} __attribute__((packed)) t7  = { 101,  15, 123 };
+
+
+struct { 
+  char x;
+  unsigned short y : 4;
+  unsigned short q : 12;
+} __attribute__((packed)) t7a  = { 101,  15, 123 };
+
+#include <stdio.h>
+
+int main() {
+  printf("1: %d, %d\n", t1.info, t1.u.id);
+  printf("2: %f, %d, %d\n", t2.info, t2.x, t2.Y);
+  printf("3: %d %s\n", t3.A, t3.C);
+  printf("4: %f %d %f\n", (double)t4.x, t4.y, (double)t4.z);
+  printf("5: %d %d %d\n", t5.x, t5.y, t5.z);
+  printf("5a: %d %d\n", t5a.x, t5a.y);
+  printf("5b: %d %d\n", t5b.x, t5b.y);
+  printf("6: %Lf %d\n", t6.x, t6.y);
+  printf("7: %d %d %d %d\n", t7.x, t7.y, t7.q, t7.z);
+  printf("7a: %d %d %d\n", t7a.x, t7a.y, t7a.q);
+  return 0;
+}





More information about the llvm-commits mailing list