xref: /minix3/external/bsd/llvm/dist/clang/test/Sema/bitfield-promote.c (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -fsyntax-only -verify %s
2*f4a2713aSLionel Sambuc // expected-no-diagnostics
3*f4a2713aSLionel Sambuc struct {unsigned x : 2;} x;
4*f4a2713aSLionel Sambuc __typeof__((x.x+=1)+1) y;
5*f4a2713aSLionel Sambuc __typeof__(x.x<<1) y;
6*f4a2713aSLionel Sambuc int y;
7*f4a2713aSLionel Sambuc 
8*f4a2713aSLionel Sambuc 
9*f4a2713aSLionel Sambuc struct { int x : 8; } x1;
10*f4a2713aSLionel Sambuc long long y1;
11*f4a2713aSLionel Sambuc __typeof__(((long long)x1.x + 1)) y1;
12*f4a2713aSLionel Sambuc 
13*f4a2713aSLionel Sambuc 
14*f4a2713aSLionel Sambuc // Check for extensions: variously sized unsigned bit-fields fitting
15*f4a2713aSLionel Sambuc // into a signed int promote to signed int.
16*f4a2713aSLionel Sambuc enum E { ec1, ec2, ec3 };
17*f4a2713aSLionel Sambuc struct S {
18*f4a2713aSLionel Sambuc   enum E          e : 2;
19*f4a2713aSLionel Sambuc   unsigned short us : 4;
20*f4a2713aSLionel Sambuc   unsigned long long ul1 : 8;
21*f4a2713aSLionel Sambuc   unsigned long long ul2 : 50;
22*f4a2713aSLionel Sambuc } s;
23*f4a2713aSLionel Sambuc 
24*f4a2713aSLionel Sambuc __typeof(s.e + s.e) x_e;
25*f4a2713aSLionel Sambuc int x_e;
26*f4a2713aSLionel Sambuc 
27*f4a2713aSLionel Sambuc __typeof(s.us + s.us) x_us;
28*f4a2713aSLionel Sambuc int x_us;
29*f4a2713aSLionel Sambuc 
30*f4a2713aSLionel Sambuc __typeof(s.ul1 + s.ul1) x_ul1;
31*f4a2713aSLionel Sambuc int x_ul1;
32*f4a2713aSLionel Sambuc 
33*f4a2713aSLionel Sambuc __typeof(s.ul2 + s.ul2) x_ul2;
34*f4a2713aSLionel Sambuc unsigned long long x_ul2;
35*f4a2713aSLionel Sambuc 
36