1 /* Test -funsigned-bitfields works. */ 2 /* Origin: Joseph Myers <jsm@polyomino.org.uk> */ 3 /* { dg-do run } */ 4 /* { dg-options "-funsigned-bitfields -fsigned-char" } */ 5 6 typedef char c; 7 typedef signed char sc; 8 typedef unsigned char uc; 9 typedef short s; 10 typedef signed short ss; 11 typedef unsigned short us; 12 typedef n; 13 typedef int i; 14 typedef signed int si; 15 typedef unsigned int ui; 16 typedef long l; 17 typedef signed long sl; 18 typedef unsigned long ul; 19 typedef long long ll; 20 typedef signed long long sll; 21 typedef unsigned long long ull; 22 23 typedef c ct; 24 typedef sc sct; 25 typedef uc uct; 26 typedef s st; 27 typedef ss sst; 28 typedef us ust; 29 typedef n nt; 30 typedef i it; 31 typedef si sit; 32 typedef ui uit; 33 typedef l lt; 34 typedef sl slt; 35 typedef ul ult; 36 typedef ll llt; 37 typedef sll sllt; 38 typedef ull ullt; 39 40 struct foo { 41 char char0 : 1; 42 c char1 : 1; 43 ct char2 : 1; 44 signed char schar0 : 1; 45 sc schar1 : 1; 46 sct schar2 : 1; 47 unsigned char uchar0 : 1; 48 uc uchar1 : 1; 49 uct uchar2 : 1; 50 short short0 : 1; 51 s short1 : 1; 52 st short2 : 1; 53 signed short sshort0 : 1; 54 ss sshort1 : 1; 55 sst sshort2 : 1; 56 unsigned short ushort0 : 1; 57 us ushort1 : 1; 58 ust ushort2 : 1; 59 __attribute__((dummy)) int0 : 1; /* { dg-warning "attribute directive ignored" } */ 60 n int1 : 1; 61 nt int2 : 1; 62 int int3 : 1; 63 i int4 : 1; 64 it int5 : 1; 65 signed int sint0 : 1; 66 si sint1 : 1; 67 sit sint2 : 1; 68 unsigned int uint0 : 1; 69 ui uint1 : 1; 70 uit uint2 : 1; 71 long long0 : 1; 72 l long1 : 1; 73 lt long2 : 1; 74 signed long slong0 : 1; 75 sl slong1 : 1; 76 slt slong2 : 1; 77 unsigned long ulong0 : 1; 78 ul ulong1 : 1; 79 ult ulong2 : 1; 80 long long llong0 : 1; 81 ll llong1 : 1; 82 llt llong2 : 1; 83 signed long long sllong0 : 1; 84 sll sllong1 : 1; 85 sllt sllong2 : 1; 86 unsigned long long ullong0 : 1; 87 ull ullong1 : 1; 88 ullt ullong2 : 1; 89 }; 90 91 struct foo x; 92 93 extern void abort (void); 94 extern void exit (int); 95 extern void *memset (void *, int, __SIZE_TYPE__); 96 97 int main(void)98main (void) 99 { 100 memset (&x, (unsigned char)-1, sizeof(x)); 101 if (x.char0 != 1 || x.char1 != 1 || x.char2 != 1 102 || x.schar0 != -1 || x.schar1 != -1 || x.schar2 != -1 103 || x.uchar0 != 1 || x.uchar1 != 1 || x.uchar2 != 1 104 || x.short0 != 1 || x.short1 != 1 || x.short2 != 1 105 || x.sshort0 != -1 || x.sshort1 != -1 || x.sshort2 != -1 106 || x.ushort0 != 1 || x.ushort1 != 1 || x.ushort2 != 1 107 || x.int0 != 1 || x.int1 != 1 || x.int2 != 1 108 || x.int3 != 1 || x.int4 != 1 || x.int5 != 1 109 || x.sint0 != -1 || x.sint1 != -1 || x.sint2 != -1 110 || x.uint0 != 1 || x.uint1 != 1 || x.uint2 != 1 111 || x.long0 != 1 || x.long1 != 1 || x.long2 != 1 112 || x.slong0 != -1 || x.slong1 != -1 || x.slong2 != -1 113 || x.ulong0 != 1 || x.ulong1 != 1 || x.ulong2 != 1 114 || x.llong0 != 1 || x.llong1 != 1 || x.llong2 != 1 115 || x.sllong0 != -1 || x.sllong1 != -1 || x.sllong2 != -1 116 || x.ullong0 != 1 || x.ullong1 != 1 || x.ullong2 != 1) 117 abort (); 118 exit (0); 119 } 120